2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
7 ## Set up all the tg machinery
19 # Don't do anything on non-topgit branch
20 if head_
=$
(git symbolic-ref
-q HEAD
); then
23 head_
="${head_#refs/heads/}"
24 git rev-parse
-q --verify "refs/top-bases/$head_" >/dev
/null ||
exit 0;;
35 local tree
file ls_line
type size
39 ls_line
="$(git ls-tree --long "$tree" "$file")" ||
40 die
"Can't ls tree for $file"
43 die
"$file is missing"
45 # check for type and size
50 # check file is of type blob (file)
51 [ "x$type" = "xblob" ] ||
52 die
"$file is not a file"
54 # check for positive size
56 die
"$file has empty size"
59 tree
=$
(git write-tree
) ||
60 die
"Can't write tree"
62 check_topfile
"$tree" ".topdeps"
63 check_topfile
"$tree" ".topmsg"
67 [ "$head_" != "$_dep" ] ||
68 die
"TopGit dependencies form a cycle: perpetrator is $_name"
71 # we only need to check newly added deps and for these if a path exists to the
73 git
diff --cached "$root_dir/.topdeps" |
75 BEGIN { in_hunk = 0; }
76 /^@@ / { in_hunk = 1; }
77 /^\+/ { if (in_hunk == 1) printf("%s\n", substr($0, 2)); }
78 /^[^@ +-]/ { in_hunk = 0; }
80 while read newly_added
; do
81 ref_exists
"$newly_added" ||
82 die
"Invalid branch as dependent: $newly_added"
84 # check for self as dep
85 [ "$head_" != "$newly_added" ] ||
86 die
"Can't have myself as dep"
88 # deps can be non-tgish but we can't run recurse_deps() on them
89 ref_exists
"refs/top-bases/$newly_added" ||
92 # recurse_deps uses dfs but takes the .topdeps from the tree,
93 # therefore no endless loop in the cycle-check
94 no_remotes
=1 recurse_deps check_cycle_name
"$newly_added"
97 # check for repetitions of deps
98 depdir
="$(mktemp -t -d tg-depdir.XXXXXX)" ||
99 die
"Can't check for multiple occurrences of deps"
100 trap "rm -rf '$depdir'" 0
101 cat_file
"(i):.topdeps" |
103 [ ! -d "$depdir/$dep" ] ||
104 die
"Multiple occurrences of the same dep: $dep"
105 mkdir
-p "$depdir/$dep" ||
106 die
"Can't check for multiple occurrences of deps"