From 119550af0c9f3cdd920e8d0e04b68b40b8485fdc Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Wed, 25 Oct 2006 22:43:47 -0400 Subject: Documentation: updates to "Everyday GIT" Remove the introduction: I think it should be obvious why we have this. (And if it isn't obvious then we've got other problems.) Replace reference to git whatchanged by git log. Miscellaneous style and grammar fixes. Signed-off-by: J. Bruce Fields Signed-off-by: Junio C Hamano diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt index b935c18..99e24a4 100644 --- a/Documentation/everyday.txt +++ b/Documentation/everyday.txt @@ -1,22 +1,7 @@ Everyday GIT With 20 Commands Or So =================================== -GIT suite has over 100 commands, and the manual page for each of -them discusses what the command does and how it is used in -detail, but until you know what command should be used in order -to achieve what you want to do, you cannot tell which manual -page to look at, and if you know that already you do not need -the manual. - -Does that mean you need to know all of them before you can use -git? Not at all. Depending on the role you play, the set of -commands you need to know is slightly different, but in any case -what you need to learn is far smaller than the full set of -commands to carry out your day-to-day work. This document is to -serve as a cheat-sheet and a set of pointers for people playing -various roles. - -<> commands are needed by people who has a +<> commands are needed by people who have a repository --- that is everybody, because every working tree of git is a repository. @@ -25,28 +10,27 @@ essential for anybody who makes a commit, even for somebody who works alone. If you work with other people, you will need commands listed in -<> section as well. +the <> section as well. -People who play <> role need to learn some more +People who play the <> role need to learn some more commands in addition to the above. <> commands are for system -administrators who are responsible to care and feed git -repositories to support developers. +administrators who are responsible for the care and feeding +of git repositories. Basic Repository[[Basic Repository]] ------------------------------------ -Everybody uses these commands to feed and care git repositories. +Everybody uses these commands to maintain git repositories. * gitlink:git-init-db[1] or gitlink:git-clone[1] to create a new repository. - * gitlink:git-fsck-objects[1] to validate the repository. + * gitlink:git-fsck-objects[1] to check the repository for errors. - * gitlink:git-prune[1] to garbage collect cruft in the - repository. + * gitlink:git-prune[1] to remove unused objects in the repository. * gitlink:git-repack[1] to pack loose objects for efficiency. @@ -78,8 +62,8 @@ $ git repack -a -d <1> $ git prune ------------ + -<1> pack all the objects reachable from the refs into one pack -and remove unneeded other packs +<1> pack all the objects reachable from the refs into one pack, +then remove the other packs. Individual Developer (Standalone)[[Individual Developer (Standalone)]] @@ -93,9 +77,6 @@ following commands. * gitlink:git-log[1] to see what happened. - * gitlink:git-whatchanged[1] to find out where things have - come from. - * gitlink:git-checkout[1] and gitlink:git-branch[1] to switch branches. @@ -120,7 +101,7 @@ following commands. Examples ~~~~~~~~ -Extract a tarball and create a working tree and a new repository to keep track of it.:: +Use a tarball as a starting point for a new repository: + ------------ $ tar zxf frotz.tar.gz @@ -203,7 +184,7 @@ $ cd my2.6 $ edit/compile/test; git commit -a -s <1> $ git format-patch origin <2> $ git pull <3> -$ git whatchanged -p ORIG_HEAD.. arch/i386 include/asm-i386 <4> +$ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <4> $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5> $ git reset --hard ORIG_HEAD <6> $ git prune <7> -- cgit v0.10.2-6-g49f6 From d9c04ba3ddd0945ef18657a2a373c5edfe86ef7c Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Thu, 26 Oct 2006 06:33:07 +0200 Subject: Remove --syslog in git-daemon inetd documentation examples. It is useless because --inetd implies --syslog. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt index 99e24a4..278161f 100644 --- a/Documentation/everyday.txt +++ b/Documentation/everyday.txt @@ -358,7 +358,7 @@ Run git-daemon to serve /pub/scm from inetd.:: ------------ $ grep git /etc/inetd.conf git stream tcp nowait nobody \ - /usr/bin/git-daemon git-daemon --inetd --syslog --export-all /pub/scm + /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm ------------ + The actual configuration line should be on one line. @@ -378,7 +378,7 @@ service git wait = no user = nobody server = /usr/bin/git-daemon - server_args = --inetd --syslog --export-all --base-path=/pub/scm + server_args = --inetd --export-all --base-path=/pub/scm log_on_failure += USERID } ------------ diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt index d562232..4b2ea2d 100644 --- a/Documentation/git-daemon.txt +++ b/Documentation/git-daemon.txt @@ -165,8 +165,7 @@ git-daemon as inetd server:: + ------------------------------------------------ git stream tcp nowait nobody /usr/bin/git-daemon - git-daemon --inetd --verbose - --syslog --export-all + git-daemon --inetd --verbose --export-all /pub/foo /pub/bar ------------------------------------------------ @@ -179,8 +178,7 @@ git-daemon as inetd server for virtual hosts:: + ------------------------------------------------ git stream tcp nowait nobody /usr/bin/git-daemon - git-daemon --inetd --verbose - --syslog --export-all + git-daemon --inetd --verbose --export-all --interpolated-path=/pub/%H%D /pub/www.example.org/software /pub/www.example.com/software -- cgit v0.10.2-6-g49f6 From 0074aba1c0d3b073c635fdc1d5754dc6a6b6b7b9 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Thu, 26 Oct 2006 05:44:49 +0200 Subject: diff-format.txt: Combined diff format documentation supplement Update example combined diff format to the current version $ git diff-tree -p -c fec9ebf16c948bcb4a8b88d0173ee63584bcde76 and provide complete first chunk in example. Document combined diff format headers: how "diff header" look like, which of "extended diff headers" are used with combined diff and how they look like, differences in two-line from-file/to-file header from non-combined diff format, chunk header format. It should be noted that combined diff format was designed for quick _content_ inspection and renames would work correctly to pick which blobs from each tree to compare but otherwise not reflected in the output (the pathnames are not shown). [jc: with minimum copyediting] Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt index 617d8f5..174d63a 100644 --- a/Documentation/diff-format.txt +++ b/Documentation/diff-format.txt @@ -156,31 +156,91 @@ to produce 'combined diff', which looks like this: ------------ diff --combined describe.c -@@@ +98,7 @@@ - return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; +index fabadb8,cc95eb0..4866510 +--- a/describe.c ++++ b/describe.c +@@@ -98,20 -98,12 +98,20 @@@ + return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; } - + - static void describe(char *arg) -static void describe(struct commit *cmit, int last_one) ++static void describe(char *arg, int last_one) { - + unsigned char sha1[20]; - + struct commit *cmit; + + unsigned char sha1[20]; + + struct commit *cmit; + struct commit_list *list; + static int initialized = 0; + struct commit_name *n; + + + if (get_sha1(arg, sha1) < 0) + + usage(describe_usage); + + cmit = lookup_commit_reference(sha1); + + if (!cmit) + + usage(describe_usage); + + + if (!initialized) { + initialized = 1; + for_each_ref(get_name); ------------ +1. It is preceded with a "git diff" header, that looks like + this (when '-c' option is used): + + diff --combined file ++ +or like this (when '--cc' option is used): + + diff --c file + +2. It is followed by one or more extended header lines + (this example shows a merge with two parents): + + index ,.. + mode ,.. + new file mode + deleted file mode , ++ +The `mode ,..` line appears only if at least one of +the is diferent from the rest. Extended headers with +information about detected contents movement (renames and +copying detection) are designed to work with diff of two + and are not used by combined diff format. + +3. It is followed by two-line from-file/to-file header + + --- a/file + +++ b/file ++ +Contrary to two-line header for traditional 'unified' diff +format, and similar to filenames in ordinary "diff header", +/dev/null is not used for creation or deletion. + +4. Chunk header format is modified to prevent people from + accidentally feeding it to `patch -p1`. Combined diff format + was created for review of merge commit changes, and was not + meant for apply. The change is similar to the change in the + extended 'index' header: + + @@@ @@@ ++ +There are (number of parents + 1) `@` characters in the chunk +header for combined diff format. + Unlike the traditional 'unified' diff format, which shows two files A and B with a single column that has `-` (minus -- appears in A but removed in B), `+` (plus -- missing in A but -added to B), or ` ` (space -- unchanged) prefix, this format +added to B), or `" "` (space -- unchanged) prefix, this format compares two or more files file1, file2,... with one file X, and shows how X differs from each of fileN. One column for each of fileN is prepended to the output line to note how X's line is different from it. A `-` character in the column N means that the line appears in -fileN but it does not appear in the last file. A `+` character +fileN but it does not appear in the result. A `+` character in the column N means that the line appears in the last file, -and fileN does not have that line. +and fileN does not have that line (in other words, the line was +added, from the point of view of that parent). In the above example output, the function signature was changed from both files (hence two `-` removals from both file1 and -- cgit v0.10.2-6-g49f6 From 0ac3056850394723c9b407754b44d3d37f1dcc3f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 26 Oct 2006 01:15:42 -0700 Subject: Documentation: clarify refname disambiguation rules. Nobody should create ambiguous refs (i.e. have tag "foobar" and branch "foobar" at the same time) that need to be disambiguated with these rules to keep sanity, but the rules are there so document them. Signed-off-by: Junio C Hamano diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 5d42570..ed938aa 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -122,14 +122,30 @@ blobs contained in a commit. your repository whose object name starts with dae86e. * An output from `git-describe`; i.e. a closest tag, followed by a - dash, a 'g', and an abbreviated object name. + dash, a `g`, and an abbreviated object name. * A symbolic ref name. E.g. 'master' typically means the commit object referenced by $GIT_DIR/refs/heads/master. If you happen to have both heads/master and tags/master, you can explicitly say 'heads/master' to tell git which one you mean. + When ambiguous, a `` is disambiguated by taking the + first match in the following rules: -* A suffix '@' followed by a date specification enclosed in a brace + . if `$GIT_DIR/` exists, that is what you mean (this is usually + useful only for `HEAD`, `FETCH_HEAD` and `MERGE_HEAD`); + + . otherwise, `$GIT_DIR/refs/` if exists; + + . otherwise, `$GIT_DIR/refs/tags/` if exists; + + . otherwise, `$GIT_DIR/refs/heads/` if exists; + + . otherwise, `$GIT_DIR/refs/remotes/` if exists; + + . otherwise, `$GIT_DIR/refs/remotes//HEAD` if exists. + +* A ref followed by the suffix '@' with a date specification + enclosed in a brace pair (e.g. '\{yesterday\}', '\{1 month 2 weeks 3 days 1 hour 1 second ago\}' or '\{1979-02-26 18:30:00\}') to specify the value of the ref at a prior point in time. This suffix may only be @@ -146,8 +162,9 @@ blobs contained in a commit. * A suffix '{tilde}' to a revision parameter means the commit object that is the th generation grand-parent of the named commit object, following only the first parent. I.e. rev~3 is - equivalent to rev{caret}{caret}{caret} which is equivalent to\ - rev{caret}1{caret}1{caret}1. + equivalent to rev{caret}{caret}{caret} which is equivalent to + rev{caret}1{caret}1{caret}1. See below for a illustration of + the usage of this form. * A suffix '{caret}' followed by an object type name enclosed in brace pair (e.g. `v0.99.8{caret}\{commit\}`) means the object -- cgit v0.10.2-6-g49f6 From d5f6a01af0658bc0ec5f068d81ba321be94526d5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 26 Oct 2006 00:05:04 -0700 Subject: combine-diff: a few more finishing touches. "new file" and "deleted file" were already reported in the original code, but the logic was not as transparent as it could have. This uses a few variables and more comments to clarify the flow. The rule is: (1) if a path exists in the merge result when no parent had it, we report "new" (otherwise it came from the parents, as opposed to have added by the evil merge). (2) if the path does not exist in the merge result, it is "deleted". Since we can say "new" and "deleted", there is no reason not to follow the /dev/null convention. This fixes it. Appending function name after @@@ ... @@@ is trivial, so implement it. Signed-off-by: Junio C Hamano diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt index 174d63a..ed4ebcb 100644 --- a/Documentation/diff-format.txt +++ b/Documentation/diff-format.txt @@ -212,9 +212,9 @@ copying detection) are designed to work with diff of two --- a/file +++ b/file + -Contrary to two-line header for traditional 'unified' diff -format, and similar to filenames in ordinary "diff header", -/dev/null is not used for creation or deletion. +Similar to two-line header for traditional 'unified' diff +format, `/dev/null` is used to signal created or deleted +files. 4. Chunk header format is modified to prevent people from accidentally feeding it to `patch -p1`. Combined diff format diff --git a/combine-diff.c b/combine-diff.c index 46d9121..01a8437 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -489,6 +489,12 @@ static void show_parent_lno(struct sline *sline, unsigned long l0, unsigned long printf(" -%lu,%lu", l0, l1-l0); } +static int hunk_comment_line(const char *bol) +{ + int ch = *bol & 0xff; + return (isalpha(ch) || ch == '_' || ch == '$'); +} + static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent, int use_color) { @@ -508,8 +514,13 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent, struct sline *sl = &sline[lno]; unsigned long hunk_end; unsigned long rlines; - while (lno <= cnt && !(sline[lno].flag & mark)) + const char *hunk_comment = NULL; + + while (lno <= cnt && !(sline[lno].flag & mark)) { + if (hunk_comment_line(sline[lno].bol)) + hunk_comment = sline[lno].bol; lno++; + } if (cnt < lno) break; else { @@ -526,6 +537,22 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent, show_parent_lno(sline, lno, hunk_end, i); printf(" +%lu,%lu ", lno+1, rlines); for (i = 0; i <= num_parent; i++) putchar(combine_marker); + + if (hunk_comment) { + int comment_end = 0; + for (i = 0; i < 40; i++) { + int ch = hunk_comment[i] & 0xff; + if (!ch || ch == '\n') + break; + if (!isspace(ch)) + comment_end = i; + } + if (comment_end) + putchar(' '); + for (i = 0; i < comment_end; i++) + putchar(hunk_comment[i]); + } + printf("%s\n", c_reset); while (lno < hunk_end) { struct lline *ll; @@ -707,6 +734,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, int use_color = opt->color_diff; const char *c_meta = diff_get_color(use_color, DIFF_METAINFO); const char *c_reset = diff_get_color(use_color, DIFF_RESET); + int added = 0; + int deleted = 0; if (rev->loginfo) show_log(rev, opt->msg_sep); @@ -722,7 +751,10 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, printf("..%s%s\n", abb, c_reset); if (mode_differs) { - int added = !!elem->mode; + deleted = !elem->mode; + + /* We say it was added if nobody had it */ + added = !deleted; for (i = 0; added && i < num_parent; i++) if (elem->parent[i].status != DIFF_STATUS_ADDED) @@ -731,7 +763,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, printf("%snew file mode %06o", c_meta, elem->mode); else { - if (!elem->mode) + if (deleted) printf("%sdeleted file ", c_meta); printf("mode "); for (i = 0; i < num_parent; i++) { @@ -743,8 +775,14 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, } printf("%s\n", c_reset); } - dump_quoted_path("--- a/", elem->path, c_meta, c_reset); - dump_quoted_path("+++ b/", elem->path, c_meta, c_reset); + if (added) + dump_quoted_path("--- /dev/", "null", c_meta, c_reset); + else + dump_quoted_path("--- a/", elem->path, c_meta, c_reset); + if (deleted) + dump_quoted_path("+++ /dev/", "null", c_meta, c_reset); + else + dump_quoted_path("+++ b/", elem->path, c_meta, c_reset); dump_sline(sline, cnt, num_parent, opt->color_diff); } free(result); -- cgit v0.10.2-6-g49f6 From 7a8ac59f2f1fdac71fdffe53eebdca382118585f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 26 Oct 2006 02:05:05 -0700 Subject: combine-diff: fix hunk_comment_line logic. We forgot that the last element of sline[] is a sentinel without the actual line. *BLUSH* Signed-off-by: Junio C Hamano diff --git a/combine-diff.c b/combine-diff.c index 01a8437..76ca651 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -491,7 +491,11 @@ static void show_parent_lno(struct sline *sline, unsigned long l0, unsigned long static int hunk_comment_line(const char *bol) { - int ch = *bol & 0xff; + int ch; + + if (!bol) + return 0; + ch = *bol & 0xff; return (isalpha(ch) || ch == '_' || ch == '$'); } -- cgit v0.10.2-6-g49f6 From 44152787bcb4fd003d1f5b8c2a7591445cee8f20 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 26 Oct 2006 02:05:59 -0700 Subject: combine-diff: honour --no-commit-id Signed-off-by: Junio C Hamano diff --git a/combine-diff.c b/combine-diff.c index 76ca651..8bf99f2 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -741,7 +741,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, int added = 0; int deleted = 0; - if (rev->loginfo) + if (rev->loginfo && !rev->no_commit_id) show_log(rev, opt->msg_sep); dump_quoted_path(dense ? "diff --cc " : "diff --combined ", elem->path, c_meta, c_reset); @@ -819,7 +819,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re if (!line_termination) inter_name_termination = 0; - if (rev->loginfo) + if (rev->loginfo && !rev->no_commit_id) show_log(rev, opt->msg_sep); if (opt->output_format & DIFF_FORMAT_RAW) { @@ -891,7 +891,7 @@ void diff_tree_combined(const unsigned char *sha1, diffopts.output_format = DIFF_FORMAT_NO_OUTPUT; diffopts.recursive = 1; - show_log_first = !!rev->loginfo; + show_log_first = !!rev->loginfo && !rev->no_commit_id; needsep = 0; /* find set of paths that everybody touches */ for (i = 0; i < num_parent; i++) { -- cgit v0.10.2-6-g49f6 From 35f401a6706238b16906666b72e207e807e71f8a Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Thu, 26 Oct 2006 10:50:20 +0200 Subject: gitweb: Use --no-commit-id in git_commit and git_commitdiff Use --no-commit-id option to git-diff-tree command in git_commit and git_commitdiff to filter out commit ID output that git-diff-tree adds when called with only one (not only for --stdin). Remove filtering commit IDs from git-diff-tree output. This option is in git since at least v1.0.0, so make use of it. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index ba7a42a..5a81b8f 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -3133,14 +3133,12 @@ sub git_commit { if (!defined $parent) { $parent = "--root"; } - open my $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts, $parent, $hash + open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id", + @diff_opts, $parent, $hash or die_error(undef, "Open git-diff-tree failed"); my @difftree = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading git-diff-tree failed"); - # filter out commit ID output - @difftree = grep(!/^[0-9a-fA-F]{40}$/, @difftree); - # non-textual hash id's can be cached my $expires; if ($hash =~ m/^[0-9a-fA-F]{40}$/) { @@ -3411,15 +3409,14 @@ sub git_commitdiff { my @difftree; if ($format eq 'html') { open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts, + "--no-commit-id", "--patch-with-raw", "--full-index", $hash_parent, $hash or die_error(undef, "Open git-diff-tree failed"); while (chomp(my $line = <$fd>)) { # empty line ends raw part of diff-tree output last unless $line; - # filter out commit ID output - push @difftree, $line - unless $line =~ m/^[0-9a-fA-F]{40}$/; + push @difftree, $line; } } elsif ($format eq 'plain') { -- cgit v0.10.2-6-g49f6 From 543551e53a8f8e52e72571e1f24f81d7f6598f9b Mon Sep 17 00:00:00 2001 From: Andy Parkins Date: Thu, 26 Oct 2006 15:17:24 +0100 Subject: Make filenames line up in git-status output When all the filenames line up it's much easier to copy and paste them somewhere else, or to remove the "modified:", "copied:", etc prefix. Signed-off-by: Andy Parkins Signed-off-by: Junio C Hamano diff --git a/wt-status.c b/wt-status.c index 4b74e68..3952809 100644 --- a/wt-status.c +++ b/wt-status.c @@ -72,25 +72,25 @@ static void wt_status_print_filepair(int t, struct diff_filepair *p) color_printf(color(WT_STATUS_HEADER), "#\t"); switch (p->status) { case DIFF_STATUS_ADDED: - color_printf(c, "new file: %s", p->one->path); break; + color_printf(c, "new file: %s", p->one->path); break; case DIFF_STATUS_COPIED: - color_printf(c, "copied: %s -> %s", + color_printf(c, "copied: %s -> %s", p->one->path, p->two->path); break; case DIFF_STATUS_DELETED: - color_printf(c, "deleted: %s", p->one->path); break; + color_printf(c, "deleted: %s", p->one->path); break; case DIFF_STATUS_MODIFIED: - color_printf(c, "modified: %s", p->one->path); break; + color_printf(c, "modified: %s", p->one->path); break; case DIFF_STATUS_RENAMED: - color_printf(c, "renamed: %s -> %s", + color_printf(c, "renamed: %s -> %s", p->one->path, p->two->path); break; case DIFF_STATUS_TYPE_CHANGED: color_printf(c, "typechange: %s", p->one->path); break; case DIFF_STATUS_UNKNOWN: - color_printf(c, "unknown: %s", p->one->path); break; + color_printf(c, "unknown: %s", p->one->path); break; case DIFF_STATUS_UNMERGED: - color_printf(c, "unmerged: %s", p->one->path); break; + color_printf(c, "unmerged: %s", p->one->path); break; default: die("bug: unhandled diff status %c", p->status); } -- cgit v0.10.2-6-g49f6 From fb8e23fae2ac9af831260079b14eabad316f3769 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Thu, 26 Oct 2006 22:21:02 +0200 Subject: diff-format.txt: Correct information about pathnames quoting in patch format Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt index 174d63a..2060ae2 100644 --- a/Documentation/diff-format.txt +++ b/Documentation/diff-format.txt @@ -144,8 +144,10 @@ the file that rename/copy produces, respectively. dissimilarity index index .. -3. TAB, LF, and backslash characters in pathnames are - represented as `\t`, `\n`, and `\\`, respectively. +3. TAB, LF, double quote and backslash characters in pathnames + are represented as `\t`, `\n`, `\"` and `\\`, respectively. + If there is need for such substitution then the whole + pathname is put in double quotes. combined diff format -- cgit v0.10.2-6-g49f6 From a8ebdb90f9e7017aa47c7824c91dfb0dd231ac85 Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Thu, 26 Oct 2006 23:32:41 +0200 Subject: git-cherry: document limit and add diagram This patch adds the diagram from the long usage string of git-cherry to its documentation, and documents the third option. I changed some of the + to - in order to save the reader from wondering where they might fit into the picture. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt index e1bf8ee..27b67b8 100644 --- a/Documentation/git-cherry.txt +++ b/Documentation/git-cherry.txt @@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream SYNOPSIS -------- -'git-cherry' [-v] [] +'git-cherry' [-v] [] [] DESCRIPTION ----------- @@ -18,7 +18,22 @@ Every commit that doesn't exist in the branch has its id (sha1) reported, prefixed by a symbol. The ones that have equivalent change already in the branch are prefixed with a minus (-) sign, and those -that only exist in the branch are prefixed with a plus (+) symbol. +that only exist in the branch are prefixed with a plus (+) symbol: + + __*__*__*__*__> + / + fork-point + \__+__+__-__+__+__-__+__> + + +If a has been given then the commits along the branch up +to and including are not reported: + + __*__*__*__*__> + / + fork-point + \__*__*____-__+__> + Because git-cherry compares the changeset rather than the commit id (sha1), you can use git-cherry to find out if a commit you made locally -- cgit v0.10.2-6-g49f6 From e2b1d1ccdd2ef4db41819bb0d242b808cfe6c422 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Fri, 27 Oct 2006 06:59:18 +0200 Subject: Documentation: add upload-archive service to git-daemon. This patch minimaly documents the upload-archive service, hoping that someone with better knowledge will improve upon. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt index 4b2ea2d..f10a269 100644 --- a/Documentation/git-daemon.txt +++ b/Documentation/git-daemon.txt @@ -37,6 +37,8 @@ from `git-fetch`, `git-ls-remote`, and `git-clone`. This is ideally suited for read-only updates, i.e., pulling from git repositories. +An `upload-archive` also exists to serve `git-archive`. + OPTIONS ------- --strict-paths:: @@ -155,6 +157,9 @@ upload-pack:: disable it by setting `daemon.uploadpack` configuration item to `false`. +upload-archive:: + This serves `git-archive --remote`. + EXAMPLES -------- git-daemon as inetd server:: -- cgit v0.10.2-6-g49f6 From f8a5da6d94baa0a90e7b383932911661bb551e1c Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Fri, 27 Oct 2006 07:00:57 +0200 Subject: Documentation: add git in /etc/services. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt index 278161f..9677671 100644 --- a/Documentation/everyday.txt +++ b/Documentation/everyday.txt @@ -353,6 +353,13 @@ example of managing a shared central repository. Examples ~~~~~~~~ +We assume the following in /etc/services:: ++ +------------ +$ grep 9418 /etc/services +git 9418/tcp # Git Version Control System +------------ + Run git-daemon to serve /pub/scm from inetd.:: + ------------ diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt index f10a269..993adc7 100644 --- a/Documentation/git-daemon.txt +++ b/Documentation/git-daemon.txt @@ -162,6 +162,13 @@ upload-archive:: EXAMPLES -------- +We assume the following in /etc/services:: ++ +------------ +$ grep 9418 /etc/services +git 9418/tcp # Git Version Control System +------------ + git-daemon as inetd server:: To set up `git-daemon` as an inetd service that handles any repository under the whitelisted set of directories, /pub/foo -- cgit v0.10.2-6-g49f6 From d6b7e0b98f8d0f84e3b2614b33b52402fefb5735 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Thu, 26 Oct 2006 12:26:44 +0200 Subject: gitweb: Check git base URLs before generating URL from it Check if each of git base URLs in @git_base_url_list is true before appending "/$project" to it to generate project URL. This fixes the error that for default configuration for gitweb in Makefile, with GITWEB_BASE_URL empty (and "++GITWEB_BASE_URL++" being "" in gitweb.cgi), we had URL of "/$project" in the summary view. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 2390603..05e7b12 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -69,7 +69,7 @@ our $strict_export = "++GITWEB_STRICT_EXPORT++"; # list of git base URLs used for URL to where fetch project from, # i.e. full URL is "$git_base_url/$project" -our @git_base_url_list = ("++GITWEB_BASE_URL++"); +our @git_base_url_list = grep { $_ ne '' } ("++GITWEB_BASE_URL++"); # default blob_plain mimetype and default charset for text/plain blob our $default_blob_plain_mimetype = 'text/plain'; -- cgit v0.10.2-6-g49f6 From 36889a5078767be8cc0189c10d235dda327c6a30 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 27 Oct 2006 14:29:55 -0700 Subject: tests: merge-recursive is usable without Python Many tests still protected themselves with $no_python; there is no need to do so anymore. Signed-off-by: Junio C Hamano diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh index 360a670..8b19d3c 100755 --- a/t/t3401-rebase-partial.sh +++ b/t/t3401-rebase-partial.sh @@ -52,13 +52,10 @@ test_expect_success \ 'rebase topic branch against new master and check git-am did not get halted' \ 'git-rebase master && test ! -d .dotest' -if test -z "$no_python" -then - test_expect_success \ +test_expect_success \ 'rebase --merge topic branch that was partially merged upstream' \ 'git-checkout -f my-topic-branch-merge && git-rebase --merge master-merge && test ! -d .git/.dotest-merge' -fi test_done diff --git a/t/t3402-rebase-merge.sh b/t/t3402-rebase-merge.sh index d34c6cf..0779aaa 100755 --- a/t/t3402-rebase-merge.sh +++ b/t/t3402-rebase-merge.sh @@ -7,12 +7,6 @@ test_description='git rebase --merge test' . ./test-lib.sh -if test "$no_python"; then - echo "Skipping: no python => no recursive merge" - test_done - exit 0 -fi - T="A quick brown fox jumps over the lazy dog." for i in 1 2 3 4 5 6 7 8 9 10 diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh index bb25315..977c498 100755 --- a/t/t3403-rebase-skip.sh +++ b/t/t3403-rebase-skip.sh @@ -10,12 +10,6 @@ test_description='git rebase --merge --skip tests' # we assume the default git-am -3 --skip strategy is tested independently # and always works :) -if test "$no_python"; then - echo "Skipping: no python => no recursive merge" - test_done - exit 0 -fi - test_expect_success setup ' echo hello > hello && git add hello && diff --git a/t/t6021-merge-criss-cross.sh b/t/t6021-merge-criss-cross.sh index 8f7366d..499cafb 100755 --- a/t/t6021-merge-criss-cross.sh +++ b/t/t6021-merge-criss-cross.sh @@ -10,12 +10,6 @@ test_description='Test criss-cross merge' . ./test-lib.sh -if test "$no_python"; then - echo "Skipping: no python => no recursive merge" - test_done - exit 0 -fi - test_expect_success 'prepare repository' \ 'echo "1 2 diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 5ac2564..497ef36 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -3,12 +3,6 @@ test_description='Merge-recursive merging renames' . ./test-lib.sh -if test "$no_python"; then - echo "Skipping: no python => no recursive merge" - test_done - exit 0 -fi - test_expect_success setup \ ' cat >A <<\EOF && -- cgit v0.10.2-6-g49f6 From 887a612fef942dd3e7dae452e2dc582738b0fb41 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 26 Oct 2006 14:41:25 +0200 Subject: gitweb: Fix up bogus $stylesheet declarations This seems to be a pre-++ residual declaration and it wasn't good for anything at all besides flooding the webserver errorlog with "omg, our in the same scope!!" warnings. [jc: the patch was bogus by defining the variable which defeated a later test that checked it with "defined", which I fixed up.] Signed-off-by: Petr Baudis Signed-off-by: Junio C Hamano diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index aceaeb7..7b2499a 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -51,12 +51,8 @@ our $site_footer = "++GITWEB_SITE_FOOTER++"; # URI of stylesheets our @stylesheets = ("++GITWEB_CSS++"); -our $stylesheet; -# default is not to define style sheet, but it can be overwritten later -undef $stylesheet; - -# URI of default stylesheet -our $stylesheet = "++GITWEB_CSS++"; +# URI of a single stylesheet, which can be overridden in GITWEB_CONFIG. +our $stylesheet = undef; # URI of GIT logo (72x27 size) our $logo = "++GITWEB_LOGO++"; # URI of GIT favicon, assumed to be image/png type -- cgit v0.10.2-6-g49f6 From 367dce2a5b80da055a0d776fe830e6f19b81bd1d Mon Sep 17 00:00:00 2001 From: Dennis Stosberg Date: Sat, 28 Oct 2006 14:12:20 +0200 Subject: Bash completion support for aliases - Add aliases to the list of available git commands. - Make completion work for aliased commands. Signed-off-by: Dennis Stosberg Signed-off-by: Junio C Hamano diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index d9cb17d..b074f4f 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -101,6 +101,23 @@ __git_complete_file () esac } +__git_aliases () +{ + git repo-config --list | grep '^alias\.' \ + | sed -e 's/^alias\.//' -e 's/=.*$//' +} + +__git_aliased_command () +{ + local cmdline=$(git repo-config alias.$1) + for word in $cmdline; do + if [ "${word##-*}" ]; then + echo $word + return + fi + done +} + _git_branch () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -264,10 +281,18 @@ _git () { if [ $COMP_CWORD = 1 ]; then COMPREPLY=($(compgen \ - -W "--version $(git help -a|egrep '^ ')" \ + -W "--version $(git help -a|egrep '^ ') \ + $(__git_aliases)" \ -- "${COMP_WORDS[COMP_CWORD]}")) else - case "${COMP_WORDS[1]}" in + local command="${COMP_WORDS[1]}" + local expansion=$(__git_aliased_command "$command") + + if [ "$expansion" ]; then + command="$expansion" + fi + + case "$command" in branch) _git_branch ;; cat-file) _git_cat_file ;; checkout) _git_checkout ;; -- cgit v0.10.2-6-g49f6 From ba7545adab83e6bea43353937eabb467bcb7d4f7 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 28 Oct 2006 19:30:05 +0200 Subject: Documentation: Update information about in git-for-each-ref Update information about value of used when it is left unspecified. Add information about `%%` and `%xx` interpolation (URL encoding). Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index d5fdcef..4af1ebf 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -38,7 +38,11 @@ OPTIONS is prefixed with an asterisk (`*`) and the ref points at a tag object, the value for the field in the object tag refers is used. When unspecified, defaults to - `%(refname)`. + `%(objectname) SPC %(objecttype) TAB %(refname)`. + It also interpolates `%%` to `%`, and `%xx` where `xx` + are hex digits interpolates to character with hex code + `xx`; for example `%00` interpolates to `\0` (NUL), + `%09` to `\t` (TAB) and `%0a` to `\n` (LF). :: If given, the name of the ref is matched against this -- cgit v0.10.2-6-g49f6 From 1dc5e55f2d2cab9ca24dc435dc2bc4f466f15ade Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 28 Oct 2006 14:25:41 -0700 Subject: Documentation: fix git-format-patch mark-up and link it from git.txt Two asterisks the SYNOPSIS section were mistaken as emphasis, and the latter backtick in "``s" were not recognized as closing backtick. Signed-off-by: Junio C Hamano diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index 4af1ebf..2bf6aef 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -7,14 +7,14 @@ git-for-each-ref - Output information on each ref SYNOPSIS -------- -'git-for-each-ref' [--count=]* [--shell|--perl|--python] [--sort=]* [--format=] [] +'git-for-each-ref' [--count=]\* [--shell|--perl|--python] [--sort=]\* [--format=] [] DESCRIPTION ----------- Iterate over all refs that match `` and show them according to the given ``, after sorting them according -to the given set of ``s. If `` is given, stop after +to the given set of ``. If `` is given, stop after showing that many refs. The interporated values in `` can optionally be quoted as string literals in the specified host language allowing their direct evaluation in that language. diff --git a/Documentation/git.txt b/Documentation/git.txt index b00607e..595cca1 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -160,6 +160,9 @@ gitlink:git-diff-stages[1]:: gitlink:git-diff-tree[1]:: Compares the content and mode of blobs found via two tree objects. +gitlink:git-for-each-ref[1]:: + Output information on each ref. + gitlink:git-fsck-objects[1]:: Verifies the connectivity and validity of the objects in the database. -- cgit v0.10.2-6-g49f6 From c60c56cc70dbf2acb4d15e3ea4f95d09020acc82 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 28 Oct 2006 19:43:40 +0200 Subject: gitweb: Move git_get_last_activity subroutine earlier This is purely cosmetic. Having git_get_* between two parse_* subroutines violated a good convention to group related things together. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 7b2499a..6714e41 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -976,6 +976,24 @@ sub git_get_project_owner { return $owner; } +sub git_get_last_activity { + my ($path) = @_; + my $fd; + + $git_dir = "$projectroot/$path"; + open($fd, "-|", git_cmd(), 'for-each-ref', + '--format=%(refname) %(committer)', + '--sort=-committerdate', + 'refs/heads') or return; + my $most_recent = <$fd>; + close $fd or return; + if ($most_recent =~ / (\d+) [-+][01]\d\d\d$/) { + my $timestamp = $1; + my $age = time - $timestamp; + return ($age, age_string($age)); + } +} + sub git_get_references { my $type = shift || ""; my %refs; @@ -1082,24 +1100,6 @@ sub parse_tag { return %tag } -sub git_get_last_activity { - my ($path) = @_; - my $fd; - - $git_dir = "$projectroot/$path"; - open($fd, "-|", git_cmd(), 'for-each-ref', - '--format=%(refname) %(committer)', - '--sort=-committerdate', - 'refs/heads') or return; - my $most_recent = <$fd>; - close $fd or return; - if ($most_recent =~ / (\d+) [-+][01]\d\d\d$/) { - my $timestamp = $1; - my $age = time - $timestamp; - return ($age, age_string($age)); - } -} - sub parse_commit { my $commit_id = shift; my $commit_text = shift; -- cgit v0.10.2-6-g49f6 From 151602df00b8e5c5b4a8193f59a94b85f9b5aebc Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Mon, 23 Oct 2006 00:37:56 +0200 Subject: gitweb: Add "next" link to commitdiff view Add a kind of "next" view in the bottom part of navigation bar for "commitdiff" view. For commitdiff between two commits: (from: _commit_) For commitdiff for one single parent commit: (parent: _commit_) For commitdiff for one merge commit (merge: _commit_ _commit_ ...) For commitdiff for root (parentless) commit (initial) where _link_ denotes hyperlink. SHA1 is shortened to 7 characters on display, everything is perhaps unnecessary esc_html on display. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 6714e41..ec46b80 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -3396,6 +3396,51 @@ sub git_commitdiff { if (!%co) { die_error(undef, "Unknown commit object"); } + + # we need to prepare $formats_nav before any parameter munging + my $formats_nav; + if ($format eq 'html') { + $formats_nav = + $cgi->a({-href => href(action=>"commitdiff_plain", + hash=>$hash, hash_parent=>$hash_parent)}, + "raw"); + + if (defined $hash_parent) { + # commitdiff with two commits given + my $hash_parent_short = $hash_parent; + if ($hash_parent =~ m/^[0-9a-fA-F]{40}$/) { + $hash_parent_short = substr($hash_parent, 0, 7); + } + $formats_nav .= + ' (from: ' . + $cgi->a({-href => href(action=>"commitdiff", + hash=>$hash_parent)}, + esc_html($hash_parent_short)) . + ')'; + } elsif (!$co{'parent'}) { + # --root commitdiff + $formats_nav .= ' (initial)'; + } elsif (scalar @{$co{'parents'}} == 1) { + # single parent commit + $formats_nav .= + ' (parent: ' . + $cgi->a({-href => href(action=>"commitdiff", + hash=>$co{'parent'})}, + esc_html(substr($co{'parent'}, 0, 7))) . + ')'; + } else { + # merge commit + $formats_nav .= + ' (merge: ' . + join(' ', map { + $cgi->a({-href => href(action=>"commitdiff", + hash=>$_)}, + esc_html(substr($_, 0, 7))); + } @{$co{'parents'}} ) . + ')'; + } + } + if (!defined $hash_parent) { $hash_parent = $co{'parent'} || '--root'; } @@ -3434,10 +3479,6 @@ sub git_commitdiff { if ($format eq 'html') { my $refs = git_get_references(); my $ref = format_ref_marker($refs, $co{'id'}); - my $formats_nav = - $cgi->a({-href => href(action=>"commitdiff_plain", - hash=>$hash, hash_parent=>$hash_parent)}, - "raw"); git_header_html(undef, $expires); git_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav); -- cgit v0.10.2-6-g49f6 From ce4231ffa80da1888a668cc7c33f5349800ab4a3 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Sun, 29 Oct 2006 21:09:40 +0100 Subject: Mention that pull can work locally in the synopsis Signed-off-by: Robin Rosenberg Signed-off-by: Junio C Hamano diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 51577fc..2a5aea7 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -3,7 +3,7 @@ git-pull(1) NAME ---- -git-pull - Pull and merge from another repository +git-pull - Pull and merge from another repository or a local branch SYNOPSIS diff --git a/Documentation/git.txt b/Documentation/git.txt index 595cca1..fff07e1 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -324,7 +324,7 @@ gitlink:git-mv[1]:: Move or rename a file, a directory, or a symlink. gitlink:git-pull[1]:: - Fetch from and merge with a remote repository. + Fetch from and merge with a remote repository or a local branch. gitlink:git-push[1]:: Update remote refs along with associated objects. -- cgit v0.10.2-6-g49f6 From b1f33d626501c3e080b324e182f1da76f49b5bf9 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Sun, 29 Oct 2006 21:09:48 +0100 Subject: Swap the porcelain and plumbing commands in the git man page This makes the documentation less confusing to newcomers. Signed-off-by: Robin Rosenberg Signed-off-by: Junio C Hamano diff --git a/Documentation/git.txt b/Documentation/git.txt index fff07e1..0679e3c 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -72,188 +72,6 @@ GIT COMMANDS We divide git into high level ("porcelain") commands and low level ("plumbing") commands. -Low-level commands (plumbing) ------------------------------ - -Although git includes its -own porcelain layer, its low-level commands are sufficient to support -development of alternative porcelains. Developers of such porcelains -might start by reading about gitlink:git-update-index[1] and -gitlink:git-read-tree[1]. - -We divide the low-level commands into commands that manipulate objects (in -the repository, index, and working tree), commands that interrogate and -compare objects, and commands that move objects and references between -repositories. - -Manipulation commands -~~~~~~~~~~~~~~~~~~~~~ -gitlink:git-apply[1]:: - Reads a "diff -up1" or git generated patch file and - applies it to the working tree. - -gitlink:git-checkout-index[1]:: - Copy files from the index to the working tree. - -gitlink:git-commit-tree[1]:: - Creates a new commit object. - -gitlink:git-hash-object[1]:: - Computes the object ID from a file. - -gitlink:git-index-pack[1]:: - Build pack idx file for an existing packed archive. - -gitlink:git-init-db[1]:: - Creates an empty git object database, or reinitialize an - existing one. - -gitlink:git-merge-index[1]:: - Runs a merge for files needing merging. - -gitlink:git-mktag[1]:: - Creates a tag object. - -gitlink:git-mktree[1]:: - Build a tree-object from ls-tree formatted text. - -gitlink:git-pack-objects[1]:: - Creates a packed archive of objects. - -gitlink:git-prune-packed[1]:: - Remove extra objects that are already in pack files. - -gitlink:git-read-tree[1]:: - Reads tree information into the index. - -gitlink:git-repo-config[1]:: - Get and set options in .git/config. - -gitlink:git-unpack-objects[1]:: - Unpacks objects out of a packed archive. - -gitlink:git-update-index[1]:: - Registers files in the working tree to the index. - -gitlink:git-write-tree[1]:: - Creates a tree from the index. - - -Interrogation commands -~~~~~~~~~~~~~~~~~~~~~~ - -gitlink:git-cat-file[1]:: - Provide content or type/size information for repository objects. - -gitlink:git-describe[1]:: - Show the most recent tag that is reachable from a commit. - -gitlink:git-diff-index[1]:: - Compares content and mode of blobs between the index and repository. - -gitlink:git-diff-files[1]:: - Compares files in the working tree and the index. - -gitlink:git-diff-stages[1]:: - Compares two "merge stages" in the index. - -gitlink:git-diff-tree[1]:: - Compares the content and mode of blobs found via two tree objects. - -gitlink:git-for-each-ref[1]:: - Output information on each ref. - -gitlink:git-fsck-objects[1]:: - Verifies the connectivity and validity of the objects in the database. - -gitlink:git-ls-files[1]:: - Information about files in the index and the working tree. - -gitlink:git-ls-tree[1]:: - Displays a tree object in human readable form. - -gitlink:git-merge-base[1]:: - Finds as good common ancestors as possible for a merge. - -gitlink:git-name-rev[1]:: - Find symbolic names for given revs. - -gitlink:git-pack-redundant[1]:: - Find redundant pack files. - -gitlink:git-rev-list[1]:: - Lists commit objects in reverse chronological order. - -gitlink:git-show-index[1]:: - Displays contents of a pack idx file. - -gitlink:git-tar-tree[1]:: - Creates a tar archive of the files in the named tree object. - -gitlink:git-unpack-file[1]:: - Creates a temporary file with a blob's contents. - -gitlink:git-var[1]:: - Displays a git logical variable. - -gitlink:git-verify-pack[1]:: - Validates packed git archive files. - -In general, the interrogate commands do not touch the files in -the working tree. - - -Synching repositories -~~~~~~~~~~~~~~~~~~~~~ - -gitlink:git-fetch-pack[1]:: - Updates from a remote repository (engine for ssh and - local transport). - -gitlink:git-http-fetch[1]:: - Downloads a remote git repository via HTTP by walking - commit chain. - -gitlink:git-local-fetch[1]:: - Duplicates another git repository on a local system by - walking commit chain. - -gitlink:git-peek-remote[1]:: - Lists references on a remote repository using - upload-pack protocol (engine for ssh and local - transport). - -gitlink:git-receive-pack[1]:: - Invoked by 'git-send-pack' to receive what is pushed to it. - -gitlink:git-send-pack[1]:: - Pushes to a remote repository, intelligently. - -gitlink:git-http-push[1]:: - Push missing objects using HTTP/DAV. - -gitlink:git-shell[1]:: - Restricted shell for GIT-only SSH access. - -gitlink:git-ssh-fetch[1]:: - Pulls from a remote repository over ssh connection by - walking commit chain. - -gitlink:git-ssh-upload[1]:: - Helper "server-side" program used by git-ssh-fetch. - -gitlink:git-update-server-info[1]:: - Updates auxiliary information on a dumb server to help - clients discover references and packs on it. - -gitlink:git-upload-archive[1]:: - Invoked by 'git-archive' to send a generated archive. - -gitlink:git-upload-pack[1]:: - Invoked by 'git-fetch-pack' to push - what are asked for. - - High-level commands (porcelain) ------------------------------- @@ -491,6 +309,188 @@ gitlink:git-stripspace[1]:: Filter out empty lines. +Low-level commands (plumbing) +----------------------------- + +Although git includes its +own porcelain layer, its low-level commands are sufficient to support +development of alternative porcelains. Developers of such porcelains +might start by reading about gitlink:git-update-index[1] and +gitlink:git-read-tree[1]. + +We divide the low-level commands into commands that manipulate objects (in +the repository, index, and working tree), commands that interrogate and +compare objects, and commands that move objects and references between +repositories. + +Manipulation commands +~~~~~~~~~~~~~~~~~~~~~ +gitlink:git-apply[1]:: + Reads a "diff -up1" or git generated patch file and + applies it to the working tree. + +gitlink:git-checkout-index[1]:: + Copy files from the index to the working tree. + +gitlink:git-commit-tree[1]:: + Creates a new commit object. + +gitlink:git-hash-object[1]:: + Computes the object ID from a file. + +gitlink:git-index-pack[1]:: + Build pack idx file for an existing packed archive. + +gitlink:git-init-db[1]:: + Creates an empty git object database, or reinitialize an + existing one. + +gitlink:git-merge-index[1]:: + Runs a merge for files needing merging. + +gitlink:git-mktag[1]:: + Creates a tag object. + +gitlink:git-mktree[1]:: + Build a tree-object from ls-tree formatted text. + +gitlink:git-pack-objects[1]:: + Creates a packed archive of objects. + +gitlink:git-prune-packed[1]:: + Remove extra objects that are already in pack files. + +gitlink:git-read-tree[1]:: + Reads tree information into the index. + +gitlink:git-repo-config[1]:: + Get and set options in .git/config. + +gitlink:git-unpack-objects[1]:: + Unpacks objects out of a packed archive. + +gitlink:git-update-index[1]:: + Registers files in the working tree to the index. + +gitlink:git-write-tree[1]:: + Creates a tree from the index. + + +Interrogation commands +~~~~~~~~~~~~~~~~~~~~~~ + +gitlink:git-cat-file[1]:: + Provide content or type/size information for repository objects. + +gitlink:git-describe[1]:: + Show the most recent tag that is reachable from a commit. + +gitlink:git-diff-index[1]:: + Compares content and mode of blobs between the index and repository. + +gitlink:git-diff-files[1]:: + Compares files in the working tree and the index. + +gitlink:git-diff-stages[1]:: + Compares two "merge stages" in the index. + +gitlink:git-diff-tree[1]:: + Compares the content and mode of blobs found via two tree objects. + +gitlink:git-for-each-ref[1]:: + Output information on each ref. + +gitlink:git-fsck-objects[1]:: + Verifies the connectivity and validity of the objects in the database. + +gitlink:git-ls-files[1]:: + Information about files in the index and the working tree. + +gitlink:git-ls-tree[1]:: + Displays a tree object in human readable form. + +gitlink:git-merge-base[1]:: + Finds as good common ancestors as possible for a merge. + +gitlink:git-name-rev[1]:: + Find symbolic names for given revs. + +gitlink:git-pack-redundant[1]:: + Find redundant pack files. + +gitlink:git-rev-list[1]:: + Lists commit objects in reverse chronological order. + +gitlink:git-show-index[1]:: + Displays contents of a pack idx file. + +gitlink:git-tar-tree[1]:: + Creates a tar archive of the files in the named tree object. + +gitlink:git-unpack-file[1]:: + Creates a temporary file with a blob's contents. + +gitlink:git-var[1]:: + Displays a git logical variable. + +gitlink:git-verify-pack[1]:: + Validates packed git archive files. + +In general, the interrogate commands do not touch the files in +the working tree. + + +Synching repositories +~~~~~~~~~~~~~~~~~~~~~ + +gitlink:git-fetch-pack[1]:: + Updates from a remote repository (engine for ssh and + local transport). + +gitlink:git-http-fetch[1]:: + Downloads a remote git repository via HTTP by walking + commit chain. + +gitlink:git-local-fetch[1]:: + Duplicates another git repository on a local system by + walking commit chain. + +gitlink:git-peek-remote[1]:: + Lists references on a remote repository using + upload-pack protocol (engine for ssh and local + transport). + +gitlink:git-receive-pack[1]:: + Invoked by 'git-send-pack' to receive what is pushed to it. + +gitlink:git-send-pack[1]:: + Pushes to a remote repository, intelligently. + +gitlink:git-http-push[1]:: + Push missing objects using HTTP/DAV. + +gitlink:git-shell[1]:: + Restricted shell for GIT-only SSH access. + +gitlink:git-ssh-fetch[1]:: + Pulls from a remote repository over ssh connection by + walking commit chain. + +gitlink:git-ssh-upload[1]:: + Helper "server-side" program used by git-ssh-fetch. + +gitlink:git-update-server-info[1]:: + Updates auxiliary information on a dumb server to help + clients discover references and packs on it. + +gitlink:git-upload-archive[1]:: + Invoked by 'git-archive' to send a generated archive. + +gitlink:git-upload-pack[1]:: + Invoked by 'git-fetch-pack' to push + what are asked for. + + Configuration Mechanism ----------------------- -- cgit v0.10.2-6-g49f6 From 9c572b21dd090a1e5c5bb397053bf8043ffe7fb4 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Sun, 29 Oct 2006 22:31:38 +0300 Subject: git-send-email: Document support for local sendmail instead of SMTP server Fix the --smtp-server option description to match reality. Signed-off-by: Sergey Vlasov Signed-off-by: Junio C Hamano diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index 481b3f5..ec0e201 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -66,8 +66,11 @@ The options available are: all that is output. --smtp-server:: - If set, specifies the outgoing SMTP server to use. Defaults to - localhost. + If set, specifies the outgoing SMTP server to use. A full + pathname of a sendmail-like program can be specified instead; + the program must support the `-i` option. Defaults to + `/usr/sbin/sendmail` or `/usr/lib/sendmail` if such program is + available, or to `localhost` otherwise. --subject:: Specify the initial subject of the email thread. -- cgit v0.10.2-6-g49f6 From 6dcfa306f2b67b733a7eb2d7ded1bc9987809edb Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Sun, 29 Oct 2006 22:31:39 +0300 Subject: git-send-email: Read the default SMTP server from the GIT config file Make the default value for --smtp-server configurable through the 'sendemail.smtpserver' option in .git/config (or $HOME/.gitconfig). Signed-off-by: Sergey Vlasov Acked-by: Ryan Anderson Signed-off-by: Junio C Hamano diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index ec0e201..4c8d907 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -68,9 +68,11 @@ The options available are: --smtp-server:: If set, specifies the outgoing SMTP server to use. A full pathname of a sendmail-like program can be specified instead; - the program must support the `-i` option. Defaults to - `/usr/sbin/sendmail` or `/usr/lib/sendmail` if such program is - available, or to `localhost` otherwise. + the program must support the `-i` option. Default value can + be specified by the 'sendemail.smtpserver' configuration + option; the built-in default is `/usr/sbin/sendmail` or + `/usr/lib/sendmail` if such program is available, or + `localhost` otherwise. --subject:: Specify the initial subject of the email thread. diff --git a/git-send-email.perl b/git-send-email.perl index c42dc3b..4c87c20 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -231,6 +231,9 @@ if (!defined $initial_reply_to && $prompting) { } if (!$smtp_server) { + $smtp_server = $repo->config('sendemail.smtpserver'); +} +if (!$smtp_server) { foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) { if (-x $_) { $smtp_server = $_; -- cgit v0.10.2-6-g49f6 From d4ff6d92c3d7020233a9b4990a3545ee54a5c033 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Sun, 29 Oct 2006 04:37:11 -0500 Subject: Allow short pack names to git-pack-objects --unpacked=. This allows us to pass just the file name of a pack rather than the complete path when we want pack-objects to consider its contents as though they were loose objects. This can be helpful if $GIT_OBJECT_DIRECTORY contains shell metacharacters which make it cumbersome to pass complete paths safely in a shell script. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano diff --git a/sha1_file.c b/sha1_file.c index e89d24c..5e6c8b8 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1203,6 +1203,24 @@ unsigned long find_pack_entry_one(const unsigned char *sha1, return 0; } +static int matches_pack_name(struct packed_git *p, const char *ig) +{ + const char *last_c, *c; + + if (!strcmp(p->pack_name, ig)) + return 0; + + for (c = p->pack_name, last_c = c; *c;) + if (*c == '/') + last_c = ++c; + else + ++c; + if (!strcmp(last_c, ig)) + return 0; + + return 1; +} + static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed) { struct packed_git *p; @@ -1214,7 +1232,7 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons if (ignore_packed) { const char **ig; for (ig = ignore_packed; *ig; ig++) - if (!strcmp(p->pack_name, *ig)) + if (!matches_pack_name(p, *ig)) break; if (*ig) continue; -- cgit v0.10.2-6-g49f6 From ce8590748b918687abc4c7cd2d432dd23f07ae40 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Sun, 29 Oct 2006 04:37:54 -0500 Subject: Only repack active packs by skipping over kept packs. During `git repack -a -d` only repack objects which are loose or which reside in an active (a non-kept) pack. This allows the user to keep large packs as-is without continuous repacking and can be very helpful on large repositories. It should also help us resolve a race condition between `git repack -a -d` and the new pack store functionality in `git-receive-pack`. Kept packs are those which have a corresponding .keep file in $GIT_OBJECT_DIRECTORY/pack. That is pack-X.pack will be kept (not repacked and not deleted) if pack-X.keep exists in the same directory when `git repack -a -d` starts. Currently this feature is not documented and there is no user interface to keep an existing pack. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano diff --git a/git-repack.sh b/git-repack.sh index 17e2452..f150a55 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -45,11 +45,19 @@ case ",$all_into_one," in args='--unpacked --incremental' ;; ,t,) - args= - - # Redundancy check in all-into-one case is trivial. - existing=`test -d "$PACKDIR" && cd "$PACKDIR" && \ - find . -type f \( -name '*.pack' -o -name '*.idx' \) -print` + if [ -d "$PACKDIR" ]; then + for e in `cd "$PACKDIR" && find . -type f -name '*.pack' \ + | sed -e 's/^\.\///' -e 's/\.pack$//'` + do + if [ -e "$PACKDIR/$e.keep" ]; then + : keep + else + args="$args --unpacked=$e.pack" + existing="$existing $e" + fi + done + fi + [ -z "$args" ] && args='--unpacked --incremental' ;; esac @@ -86,17 +94,16 @@ fi if test "$remove_redundant" = t then - # We know $existing are all redundant only when - # all-into-one is used. - if test "$all_into_one" != '' && test "$existing" != '' + # We know $existing are all redundant. + if [ -n "$existing" ] then sync ( cd "$PACKDIR" && for e in $existing do case "$e" in - ./pack-$name.pack | ./pack-$name.idx) ;; - *) rm -f $e ;; + pack-$name) ;; + *) rm -f "$e.pack" "$e.idx" "$e.keep" ;; esac done ) -- cgit v0.10.2-6-g49f6 From b8077709243138c3d8cc1c096c06a95b250a9001 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Sun, 29 Oct 2006 04:41:59 -0500 Subject: Teach git-index-pack how to keep a pack file. To prevent a race condition between `index-pack --stdin` and `repack -a -d` where the repack deletes the newly created pack file before any refs are updated to reference objects contained within it we mark the pack file as one that should be kept. This removes it from the list of packs that `repack -a -d` will consider for removal. Callers such as `receive-pack` which want to invoke `index-pack` should use this new --keep option to prevent the newly created pack and index file pair from being deleted before they have finished any related ref updates. Only after all ref updates have been finished should the associated .keep file be removed. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt index 9fa4847..1235416 100644 --- a/Documentation/git-index-pack.txt +++ b/Documentation/git-index-pack.txt @@ -9,7 +9,7 @@ git-index-pack - Build pack index file for an existing packed archive SYNOPSIS -------- 'git-index-pack' [-v] [-o ] -'git-index-pack' --stdin [--fix-thin] [-v] [-o ] [] +'git-index-pack' --stdin [--fix-thin] [--keep] [-v] [-o ] [] DESCRIPTION @@ -38,7 +38,10 @@ OPTIONS instead and a copy is then written to . If is not specified, the pack is written to objects/pack/ directory of the current git repository with - a default name determined from the pack content. + a default name determined from the pack content. If + is not specified consider using --keep to + prevent a race condition between this process and + gitlink::git-repack[1] . --fix-thin:: It is possible for gitlink:git-pack-objects[1] to build @@ -48,7 +51,22 @@ OPTIONS and they must be included in the pack for that pack to be self contained and indexable. Without this option any attempt to index a thin pack will fail. This option only makes sense in - conjonction with --stdin. + conjunction with --stdin. + +--keep:: + Before moving the index into its final destination + create an empty .keep file for the associated pack file. + This option is usually necessary with --stdin to prevent a + simultaneous gitlink:git-repack[1] process from deleting + the newly constructed pack and index before refs can be + updated to use objects contained in the pack. + +--keep='why':: + Like --keep create a .keep file before moving the index into + its final destination, but rather than creating an empty file + place 'why' followed by an LF into the .keep file. The 'why' + message can later be searched for within all .keep files to + locate any which have outlived their usefulness. Author diff --git a/index-pack.c b/index-pack.c index 866a054..b37dd78 100644 --- a/index-pack.c +++ b/index-pack.c @@ -10,7 +10,7 @@ #include static const char index_pack_usage[] = -"git-index-pack [-v] [-o ] { | --stdin [--fix-thin] [] }"; +"git-index-pack [-v] [-o ] [{ ---keep | --keep= }] { | --stdin [--fix-thin] [] }"; struct object_entry { @@ -754,6 +754,7 @@ static const char *write_index_file(const char *index_name, unsigned char *sha1) static void final(const char *final_pack_name, const char *curr_pack_name, const char *final_index_name, const char *curr_index_name, + const char *keep_name, const char *keep_msg, unsigned char *sha1) { char name[PATH_MAX]; @@ -780,6 +781,23 @@ static void final(const char *final_pack_name, const char *curr_pack_name, } } + if (keep_msg) { + int keep_fd, keep_msg_len = strlen(keep_msg); + if (!keep_name) { + snprintf(name, sizeof(name), "%s/pack/pack-%s.keep", + get_object_directory(), sha1_to_hex(sha1)); + keep_name = name; + } + keep_fd = open(keep_name, O_RDWR | O_CREAT, 0600); + if (keep_fd < 0) + die("cannot write keep file"); + if (keep_msg_len > 0) { + write_or_die(keep_fd, keep_msg, keep_msg_len); + write_or_die(keep_fd, "\n", 1); + } + close(keep_fd); + } + if (final_pack_name != curr_pack_name) { if (!final_pack_name) { snprintf(name, sizeof(name), "%s/pack/pack-%s.pack", @@ -807,7 +825,8 @@ int main(int argc, char **argv) int i, fix_thin_pack = 0; const char *curr_pack, *pack_name = NULL; const char *curr_index, *index_name = NULL; - char *index_name_buf = NULL; + const char *keep_name = NULL, *keep_msg = NULL; + char *index_name_buf = NULL, *keep_name_buf = NULL; unsigned char sha1[20]; for (i = 1; i < argc; i++) { @@ -818,6 +837,10 @@ int main(int argc, char **argv) from_stdin = 1; } else if (!strcmp(arg, "--fix-thin")) { fix_thin_pack = 1; + } else if (!strcmp(arg, "--keep")) { + keep_msg = ""; + } else if (!strncmp(arg, "--keep=", 7)) { + keep_msg = arg + 7; } else if (!strcmp(arg, "-v")) { verbose = 1; } else if (!strcmp(arg, "-o")) { @@ -848,6 +871,16 @@ int main(int argc, char **argv) strcpy(index_name_buf + len - 5, ".idx"); index_name = index_name_buf; } + if (keep_msg && !keep_name && pack_name) { + int len = strlen(pack_name); + if (!has_extension(pack_name, ".pack")) + die("packfile name '%s' does not end with '.pack'", + pack_name); + keep_name_buf = xmalloc(len); + memcpy(keep_name_buf, pack_name, len - 5); + strcpy(keep_name_buf + len - 5, ".keep"); + keep_name = keep_name_buf; + } curr_pack = open_pack_file(pack_name); parse_pack_header(); @@ -880,9 +913,13 @@ int main(int argc, char **argv) } free(deltas); curr_index = write_index_file(index_name, sha1); - final(pack_name, curr_pack, index_name, curr_index, sha1); + final(pack_name, curr_pack, + index_name, curr_index, + keep_name, keep_msg, + sha1); free(objects); free(index_name_buf); + free(keep_name_buf); if (!from_stdin) printf("%s\n", sha1_to_hex(sha1)); -- cgit v0.10.2-6-g49f6 From 861ed12106d7f8e65b90c8a5ed4a026cd71a044d Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Mon, 30 Oct 2006 17:34:50 -0500 Subject: Remove unused variable in receive-pack. We aren't using this return code variable for anything so lets just get rid of it to keep this section of code clean. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano diff --git a/receive-pack.c b/receive-pack.c index ea2dbd4..675b1c1 100644 --- a/receive-pack.c +++ b/receive-pack.c @@ -273,11 +273,10 @@ static void read_head_info(void) } } -static const char *unpack(int *error_code) +static const char *unpack(void) { int code = run_command_v_opt(1, unpacker, RUN_GIT_CMD); - *error_code = 0; switch (code) { case 0: return NULL; @@ -294,7 +293,6 @@ static const char *unpack(int *error_code) case -ERR_RUN_COMMAND_WAITPID_NOEXIT: return "unpacker died strangely"; default: - *error_code = -code; return "unpacker exited with error code"; } } @@ -345,8 +343,7 @@ int main(int argc, char **argv) read_head_info(); if (commands) { - int code; - const char *unpack_status = unpack(&code); + const char *unpack_status = unpack(); if (!unpack_status) execute_commands(); if (report_status) -- cgit v0.10.2-6-g49f6