From 228e2eb67e9f15983519f472cc1566a3dd857f9c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 22 Dec 2006 15:21:55 -0800 Subject: [PATCH 01/20] merge and reset: adjust for "reset --hard" messages An earlier commit made "reset --hard" chattier but leaking its message from "git rebase" (which calls it when first rewinding the current branch to prepare replaying our own changes) without explanation was confusing, so add an extra message to mention it. Inside restorestate in merge (which is rarely exercised codepath, where more than one strategies are attempted), resetting to the original state uses "reset --hard" -- this can be squelched entirely. Signed-off-by: Junio C Hamano --- git-merge.sh | 2 +- git-rebase.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/git-merge.sh b/git-merge.sh index 4ebfcf65d9..aec215e725 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -32,7 +32,7 @@ savestate() { restorestate() { if test -f "$GIT_DIR/MERGE_SAVE" then - git reset --hard $head + git reset --hard $head >/dev/null cpio -iuv <"$GIT_DIR/MERGE_SAVE" git-update-index --refresh >/dev/null fi diff --git a/git-rebase.sh b/git-rebase.sh index 2b4f3477fa..ece31425d0 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -292,6 +292,7 @@ then fi # Rewind the head to "$onto"; this saves our current head in ORIG_HEAD. +echo "First, rewinding head to replay your work on top of it..." git-reset --hard "$onto" # If the $onto is a proper descendant of the tip of the branch, then From fb8696d9d82e78fe829fdd95ff9ff10fdfa52ef9 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 22 Dec 2006 15:25:21 -0800 Subject: [PATCH 02/20] default pull: forget about "newbie protection" for now. This will not be backward compatible no matter how you cut it. Shelve it for now until somebody comes up with a better way to determine when we can safely refuse to use the first set of branchse for merging without upsetting valid workflows. Signed-off-by: Junio C Hamano --- git-parse-remote.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/git-parse-remote.sh b/git-parse-remote.sh index f163821d03..b163d22ddb 100755 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -145,13 +145,6 @@ canon_refs_list_for_fetch () { merge_branches=$(git-repo-config \ --get-all "branch.${curr_branch}.merge") fi - # If we are fetching only one branch, then first branch - # is the only thing that makes sense to merge anyway, - # so there is no point refusing that traditional rule. - if test $# != 1 && test "z$merge_branches" = z - then - merge_branches=..this..would..never..match.. - fi fi for ref do From ea560e6d64374ec1f6c163c276319a3da21a1345 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 22 Dec 2006 15:37:48 -0800 Subject: [PATCH 03/20] Do not support "partial URL shorthand" anymore. We used to support specifying the top part of remote URL in remotes and use that as a short-hand for the URL. $ cat .git/remotes/jgarzik URL: git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/ $ git pull jgarzik/misc-2.6 This is confusing when somebody attempts to do this: $ git pull origin/foo which is not syntactically correct (unless you have origin/foo.git repository) and should fail, but it resulted in a mysterious access to the 'foo' subdirectory of the origin repository. Which was what it was designed to do, but because this is an oddball "feature" I suspect nobody uses, let's remove it. Signed-off-by: Junio C Hamano --- git-parse-remote.sh | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/git-parse-remote.sh b/git-parse-remote.sh index b163d22ddb..aaef861ada 100755 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -7,18 +7,7 @@ GIT_DIR=$(git-rev-parse --git-dir 2>/dev/null) || :; get_data_source () { case "$1" in */*) - # Not so fast. This could be the partial URL shorthand... - token=$(expr "z$1" : 'z\([^/]*\)/') - remainder=$(expr "z$1" : 'z[^/]*/\(.*\)') - if test "$(git-repo-config --get "remote.$token.url")" - then - echo config-partial - elif test -f "$GIT_DIR/branches/$token" - then - echo branches-partial - else - echo '' - fi + echo '' ;; *) if test "$(git-repo-config --get "remote.$1.url")" @@ -40,12 +29,7 @@ get_remote_url () { data_source=$(get_data_source "$1") case "$data_source" in '') - echo "$1" ;; - config-partial) - token=$(expr "z$1" : 'z\([^/]*\)/') - remainder=$(expr "z$1" : 'z[^/]*/\(.*\)') - url=$(git-repo-config --get "remote.$token.url") - echo "$url/$remainder" + echo "$1" ;; config) git-repo-config --get "remote.$1.url" @@ -54,14 +38,10 @@ get_remote_url () { sed -ne '/^URL: */{ s///p q - }' "$GIT_DIR/remotes/$1" ;; + }' "$GIT_DIR/remotes/$1" + ;; branches) - sed -e 's/#.*//' "$GIT_DIR/branches/$1" ;; - branches-partial) - token=$(expr "z$1" : 'z\([^/]*\)/') - remainder=$(expr "z$1" : 'z[^/]*/\(.*\)') - url=$(sed -e 's/#.*//' "$GIT_DIR/branches/$token") - echo "$url/$remainder" + sed -e 's/#.*//' "$GIT_DIR/branches/$1" ;; *) die "internal error: get-remote-url $1" ;; @@ -77,7 +57,7 @@ get_default_remote () { get_remote_default_refs_for_push () { data_source=$(get_data_source "$1") case "$data_source" in - '' | config-partial | branches | branches-partial) + '' | branches) ;; # no default push mapping, just send matching refs. config) git-repo-config --get-all "remote.$1.push" ;; @@ -196,7 +176,7 @@ canon_refs_list_for_fetch () { get_remote_default_refs_for_fetch () { data_source=$(get_data_source "$1") case "$data_source" in - '' | config-partial | branches-partial) + '') echo "HEAD:" ;; config) canon_refs_list_for_fetch -d "$1" \ From 95ca1c6cb76ae01528f70c5ed437a79887a60775 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 22 Dec 2006 22:46:11 -0800 Subject: [PATCH 04/20] Really fix headers for __FreeBSD__ The symbol to detect FreeBSD is __FreeBSD__, not __FreeBSD. Signed-off-by: Junio C Hamano --- git-compat-util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-compat-util.h b/git-compat-util.h index a55b923894..f79365b362 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -11,7 +11,7 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -#if !defined(__APPLE__) && !defined(__FreeBSD) +#if !defined(__APPLE__) && !defined(__FreeBSD__) #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ #endif From a6782bc572530be6f7d799f18d3e79dd6a406294 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 22 Dec 2006 22:48:46 -0800 Subject: [PATCH 05/20] git-tag: lose exit after die We are not running under /bin/resurrection shell ;-) Signed-off-by: Junio C Hamano --- git-tag.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/git-tag.sh b/git-tag.sh index 36cd6aa256..e1bfa82f1e 100755 --- a/git-tag.sh +++ b/git-tag.sh @@ -40,7 +40,6 @@ do message="$1" if test "$#" = "0"; then die "error: option -m needs an argument" - exit 2 else message_given=1 fi @@ -50,7 +49,6 @@ do shift if test "$#" = "0"; then die "error: option -F needs an argument" - exit 2 else message="$(cat "$1")" message_given=1 From 40f656cd0214355df4c29aea315bfc2e9d983516 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 22 Dec 2006 22:18:03 -0800 Subject: [PATCH 06/20] Remove NO_ACCURATE_DIFF options from build systems The code no longer uses it, as we have --inaccurate-eof in git-apply. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- Makefile | 6 ------ configure.ac | 3 --- 2 files changed, 9 deletions(-) diff --git a/Makefile b/Makefile index 76511045a8..4362297e00 100644 --- a/Makefile +++ b/Makefile @@ -79,9 +79,6 @@ all: # # Define NO_ICONV if your libc does not properly support iconv. # -# Define NO_ACCURATE_DIFF if your diff program at least sometimes misses -# a missing newline at the end of the file. -# # Define USE_NSEC below if you want git to care about sub-second file mtimes # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely @@ -549,9 +546,6 @@ else endif endif endif -ifdef NO_ACCURATE_DIFF - BASIC_CFLAGS += -DNO_ACCURATE_DIFF -endif ifdef NO_PERL_MAKEMAKER export NO_PERL_MAKEMAKER endif diff --git a/configure.ac b/configure.ac index e153d53823..7cfb3a0666 100644 --- a/configure.ac +++ b/configure.ac @@ -235,9 +235,6 @@ AC_SUBST(NO_SETENV) # # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link. # Enable it on Windows. By default, symrefs are still used. -# -# Define NO_ACCURATE_DIFF if your diff program at least sometimes misses -# a missing newline at the end of the file. ## Site configuration (override autodetection) ## --with-PACKAGE[=ARG] and --without-PACKAGE From 4de0f9f9b6ed1731de00b67952504e5a783f54a4 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 22 Dec 2006 14:56:15 +0100 Subject: [PATCH 07/20] vc-git: Ignore errors caused by a non-existent directory in vc-git-registered. Signed-off-by: Alexandre Julliard Signed-off-by: Junio C Hamano --- contrib/emacs/vc-git.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el index 8b6361922f..3eb4bd19e9 100644 --- a/contrib/emacs/vc-git.el +++ b/contrib/emacs/vc-git.el @@ -58,8 +58,9 @@ (with-temp-buffer (let* ((dir (file-name-directory file)) (name (file-relative-name file dir))) - (when dir (cd dir)) - (and (ignore-errors (eq 0 (call-process "git" nil '(t nil) nil "ls-files" "-c" "-z" "--" name))) + (and (ignore-errors + (when dir (cd dir)) + (eq 0 (call-process "git" nil '(t nil) nil "ls-files" "-c" "-z" "--" name))) (let ((str (buffer-string))) (and (> (length str) (length name)) (string= (substring str 0 (1+ (length name))) (concat name "\0")))))))) From 4b1552238ec3b8b711f60b2b65265a751a40f5ff Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 22 Dec 2006 21:59:24 -0800 Subject: [PATCH 08/20] git-svn: enable common fetch/commit options for dcommit dcommit does commits and fetches, so all options used for those should work, too, including --authors-file. Reported missing by Nicolas Vilz. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-svn.perl b/git-svn.perl index 07748bc3e3..4288a05c16 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -111,7 +111,7 @@ my %cmd = ( { 'merge|m|M' => \$_merge, 'strategy|s=s' => \$_strategy, 'dry-run|n' => \$_dry_run, - %cmt_opts } ], + %cmt_opts, %fc_opts } ], 'set-tree' => [ \&commit, "Set an SVN repository to a git tree-ish", { 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ], 'show-ignore' => [ \&show_ignore, "Show svn:ignore listings", From c321f00d09f56dcf2f149757a2a337f3732f3097 Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Fri, 22 Dec 2006 08:56:25 -0500 Subject: [PATCH 09/20] Keep "git --git-dir" from causing a bus error. The option checking code for --git-dir had an off by 1 error that would cause it to access uninitialized memory if it was the last argument. This causes it to display an error and display the usage string instead. Signed-off-by: Brian Gernhardt Signed-off-by: Junio C Hamano --- git.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git.c b/git.c index 73cf4d4e01..7bb61d8375 100644 --- a/git.c +++ b/git.c @@ -59,8 +59,10 @@ static int handle_options(const char*** argv, int* argc) } else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) { setup_pager(); } else if (!strcmp(cmd, "--git-dir")) { - if (*argc < 1) - return -1; + if (*argc < 2) { + fprintf(stderr, "No directory given for --git-dir.\n" ); + usage(git_usage_string); + } setenv("GIT_DIR", (*argv)[1], 1); (*argv)++; (*argc)--; From f49006b0c79bb74bc500a9a3a883e929fa0f803e Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Fri, 22 Dec 2006 08:58:39 -0500 Subject: [PATCH 10/20] Make git-show-branch options similar to git-branch. Branch has "-r" for remote branches and "-a" for local and remote. It seems logical to mirror that in show-branch. Also removes the dubiously useful "--tags" option (as part of changing the meaning for "--all"). Signed-off-by: Brian Gernhardt Signed-off-by: Junio C Hamano --- Documentation/git-show-branch.txt | 10 ++++---- builtin-show-branch.c | 40 ++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt index 948ff10e6c..dafacd4308 100644 --- a/Documentation/git-show-branch.txt +++ b/Documentation/git-show-branch.txt @@ -8,7 +8,7 @@ git-show-branch - Show branches and their commits SYNOPSIS -------- [verse] -'git-show-branch' [--all] [--heads] [--tags] [--topo-order] [--current] +'git-show-branch' [--all] [--remotes] [--topo-order] [--current] [--more= | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [ | ]... @@ -37,9 +37,11 @@ OPTIONS branches under $GIT_DIR/refs/heads/topic, giving `topic/*` would show all of them. ---all --heads --tags:: - Show all refs under $GIT_DIR/refs, $GIT_DIR/refs/heads, - and $GIT_DIR/refs/tags, respectively. +-r|--remotes:: + Show the remote-tracking branches. + +-a|--all:: + Show both remote-tracking branches and local branches. --current:: With this option, the command includes the current diff --git a/builtin-show-branch.c b/builtin-show-branch.c index b9d9781d4d..c67f2fa2fe 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -4,7 +4,7 @@ #include "builtin.h" static const char show_branch_usage[] = -"git-show-branch [--sparse] [--current] [--all] [--heads] [--tags] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [...] | --reflog[=n] "; +"git-show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [...] | --reflog[=n] "; static int default_num; static int default_alloc; @@ -383,6 +383,20 @@ static int append_head_ref(const char *refname, const unsigned char *sha1, int f return append_ref(refname + ofs, sha1, flag, cb_data); } +static int append_remote_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +{ + unsigned char tmp[20]; + int ofs = 13; + if (strncmp(refname, "refs/remotes/", ofs)) + return 0; + /* If both heads/foo and tags/foo exists, get_sha1 would + * get confused. + */ + if (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1)) + ofs = 5; + return append_ref(refname + ofs, sha1, flag, cb_data); +} + static int append_tag_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) { if (strncmp(refname, "refs/tags/", 10)) @@ -423,16 +437,16 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i return append_ref(refname, sha1, flag, cb_data); } -static void snarf_refs(int head, int tag) +static void snarf_refs(int head, int remotes) { if (head) { int orig_cnt = ref_name_cnt; for_each_ref(append_head_ref, NULL); sort_ref_range(orig_cnt, ref_name_cnt); } - if (tag) { + if (remotes) { int orig_cnt = ref_name_cnt; - for_each_ref(append_tag_ref, NULL); + for_each_ref(append_remote_ref, NULL); sort_ref_range(orig_cnt, ref_name_cnt); } } @@ -554,7 +568,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) struct commit_list *list = NULL, *seen = NULL; unsigned int rev_mask[MAX_REVS]; int num_rev, i, extra = 0; - int all_heads = 0, all_tags = 0; + int all_heads = 0, all_remotes = 0; int all_mask, all_revs; int lifo = 1; char head[128]; @@ -586,12 +600,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) ac--; av++; break; } - else if (!strcmp(arg, "--all")) - all_heads = all_tags = 1; - else if (!strcmp(arg, "--heads")) - all_heads = 1; - else if (!strcmp(arg, "--tags")) - all_tags = 1; + else if (!strcmp(arg, "--all") || !strcmp(arg, "-a")) + all_heads = all_remotes = 1; + else if (!strcmp(arg, "--remotes") || !strcmp(arg, "-r")) + all_remotes = 1; else if (!strcmp(arg, "--more")) extra = 1; else if (!strcmp(arg, "--list")) @@ -636,11 +648,11 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) usage(show_branch_usage); /* If nothing is specified, show all branches by default */ - if (ac + all_heads + all_tags == 0) + if (ac + all_heads + all_remotes == 0) all_heads = 1; - if (all_heads + all_tags) - snarf_refs(all_heads, all_tags); + if (all_heads + all_remotes) + snarf_refs(all_heads, all_remotes); if (reflog) { int reflen; if (!ac) From aaca9675a494fb42e7caa182ecb89c1951cafefa Mon Sep 17 00:00:00 2001 From: Robert Fitzsimons Date: Fri, 22 Dec 2006 19:38:12 +0000 Subject: [PATCH 11/20] gitweb: Add missing show '...' links change. Part of the patch for "gitweb: Show '...' links in "summary" view only if there are more items" (313ce8cee665447e4476d7e8985b270346a8e5a1) is missing. Add it back in. Signed-off-by: Robert Fitzsimons Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 1 + 1 file changed, 1 insertion(+) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index ebbc397ee8..80c04b88da 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2983,6 +2983,7 @@ sub git_summary { if (@forklist) { git_print_header_div('forks'); git_project_list_body(\@forklist, undef, 0, 15, + $#forklist <= 15 ? undef : $cgi->a({-href => href(action=>"forks")}, "..."), 'noheader'); } From 0ff5ec70c7d4fb5f176da5e05897c316fda82584 Mon Sep 17 00:00:00 2001 From: Robert Fitzsimons Date: Fri, 22 Dec 2006 19:38:13 +0000 Subject: [PATCH 12/20] gitweb: optimize git_get_last_activity. Only return one line of output and we don't need the refname value. Signed-off-by: Robert Fitzsimons Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 80c04b88da..01e3a8adaa 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1139,8 +1139,9 @@ sub git_get_last_activity { $git_dir = "$projectroot/$path"; open($fd, "-|", git_cmd(), 'for-each-ref', - '--format=%(refname) %(committer)', + '--format=%(committer)', '--sort=-committerdate', + '--count=1', 'refs/heads') or return; my $most_recent = <$fd>; close $fd or return; From 3fcf06be5d02de15992d11482cfae82dc058261b Mon Sep 17 00:00:00 2001 From: Robert Fitzsimons Date: Fri, 22 Dec 2006 19:38:14 +0000 Subject: [PATCH 13/20] gitweb: optimize git_shortlog_body. Don't call gitweb_have_snapshot from within the loop. Signed-off-by: Robert Fitzsimons Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 01e3a8adaa..d2ddac8bf3 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2636,6 +2636,8 @@ sub git_shortlog_body { # uses global variable $project my ($revlist, $from, $to, $refs, $extra) = @_; + my $have_snapshot = gitweb_have_snapshot(); + $from = 0 unless defined $from; $to = $#{$revlist} if (!defined $to || $#{$revlist} < $to); @@ -2663,7 +2665,7 @@ sub git_shortlog_body { $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " . $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") . " | " . $cgi->a({-href => href(action=>"tree", hash=>$commit, hash_base=>$commit)}, "tree"); - if (gitweb_have_snapshot()) { + if ($have_snapshot) { print " | " . $cgi->a({-href => href(action=>"snapshot", hash=>$commit)}, "snapshot"); } print "\n" . From a979d1289be6a3999d7e89bf0359ebf28075fc6b Mon Sep 17 00:00:00 2001 From: Robert Fitzsimons Date: Fri, 22 Dec 2006 19:38:15 +0000 Subject: [PATCH 14/20] gitweb: optimize git_summary. We don't need to call git_get_head_hash at all just pass in "HEAD" and use the return id field. Signed-off-by: Robert Fitzsimons Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index d2ddac8bf3..b0e6fdfb9d 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2911,9 +2911,9 @@ sub git_project_index { sub git_summary { my $descr = git_get_project_description($project) || "none"; - my $head = git_get_head_hash($project); - my %co = parse_commit($head); + my %co = parse_commit("HEAD"); my %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'}); + my $head = $co{'id'}; my $owner = git_get_project_owner($project); @@ -2960,7 +2960,7 @@ sub git_summary { # we need to request one more than 16 (0..15) to check if # those 16 are all open my $fd, "-|", git_cmd(), "rev-list", "--max-count=17", - git_get_head_hash($project), "--" + $head, "--" or die_error(undef, "Open git-rev-list failed"); my @revlist = map { chomp; $_ } <$fd>; close $fd; From 0a5761746ca046d546da6afc2b0079706a6629e0 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Fri, 22 Dec 2006 15:06:54 -0500 Subject: [PATCH 15/20] checkout: make the message about the need for a new branch a bit clearer Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- git-checkout.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/git-checkout.sh b/git-checkout.sh index 4192a99fec..92ec069a3a 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -146,8 +146,11 @@ fi [ -z "$branch$newbranch" ] && [ "$new" != "$old" ] && - die "git checkout: to checkout the requested commit you need to specify - a name for a new branch which is created and switched to" + die "git checkout: provided reference cannot be checked out directly + + You need -b to associate a new branch with the wanted checkout. Example: + git checkout -b $arg +" if [ "X$old" = X ] then From 8e574fb542eaf7f41d5416b2cf65b5c2e93829d6 Mon Sep 17 00:00:00 2001 From: Robert Fitzsimons Date: Sat, 23 Dec 2006 03:35:14 +0000 Subject: [PATCH 16/20] gitweb: Use rev-list pattern search options. Use rev-list pattern search options instead of hand coded perl. Signed-off-by: Robert Fitzsimons Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index b0e6fdfb9d..c1e8bbc3cb 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -4176,20 +4176,20 @@ sub git_search { print "\n"; my $alternate = 1; if ($searchtype eq 'commit' or $searchtype eq 'author' or $searchtype eq 'committer') { + my $greptype; + if ($searchtype eq 'commit') { + $greptype = "--grep="; + } elsif ($searchtype eq 'author') { + $greptype = "--author="; + } elsif ($searchtype eq 'committer') { + $greptype = "--committer="; + } $/ = "\0"; open my $fd, "-|", git_cmd(), "rev-list", - "--header", "--parents", $hash, "--" + "--header", "--parents", ($greptype . $searchtext), + $hash, "--" or next; while (my $commit_text = <$fd>) { - if (!grep m/$searchtext/i, $commit_text) { - next; - } - if ($searchtype eq 'author' && !grep m/\nauthor .*$searchtext/i, $commit_text) { - next; - } - if ($searchtype eq 'committer' && !grep m/\ncommitter .*$searchtext/i, $commit_text) { - next; - } my @commit_lines = split "\n", $commit_text; my %co = parse_commit(undef, \@commit_lines); if (!%co) { From 9d032c725034e7c072f8c1a3e11855594c2fc0af Mon Sep 17 00:00:00 2001 From: Robert Fitzsimons Date: Sat, 23 Dec 2006 03:35:15 +0000 Subject: [PATCH 17/20] gitweb: Require a minimum of two character for the search text. Signed-off-by: Robert Fitzsimons Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index c1e8bbc3cb..9061c4a75e 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -351,6 +351,9 @@ if (defined $searchtext) { if ($searchtext =~ m/[^a-zA-Z0-9_\.\/\-\+\:\@ ]/) { die_error(undef, "Invalid search parameter"); } + if (length($searchtext) < 2) { + die_error(undef, "At least two characters are required for search parameter"); + } $searchtext = quotemeta $searchtext; } From 6be935115b4a3bfa9062875a569d4a018ac372e2 Mon Sep 17 00:00:00 2001 From: Robert Fitzsimons Date: Sat, 23 Dec 2006 03:35:16 +0000 Subject: [PATCH 18/20] gitweb: Allow search to be disabled from the config file. Signed-off-by: Robert Fitzsimons Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 9061c4a75e..9a4f3b4841 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -128,6 +128,12 @@ our %feature = ( # => [content-encoding, suffix, program] 'default' => ['x-gzip', 'gz', 'gzip']}, + # Enable text search, which will list the commits which match author, + # committer or commit text to a given string. Enabled by default. + 'search' => { + 'override' => 0, + 'default' => [1]}, + # Enable the pickaxe search, which will list the commits that modified # a given string in a file. This can be practical and quite faster # alternative to 'blame', but still potentially CPU-intensive. @@ -1730,6 +1736,9 @@ EOF print " / $action"; } print "\n"; + } + my ($have_search) = gitweb_check_feature('search'); + if ((defined $project) && ($have_search)) { if (!defined $searchtext) { $searchtext = ""; } @@ -4151,6 +4160,10 @@ sub git_history { } sub git_search { + my ($have_search) = gitweb_check_feature('search'); + if (!$have_search) { + die_error('403 Permission denied', "Permission denied"); + } if (!defined $searchtext) { die_error(undef, "Text field empty"); } From d9606e85cdf26b738786b5e5289bf8335656e95e Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 23 Dec 2006 03:44:00 -0500 Subject: [PATCH 19/20] Use extended SHA1 syntax in merge-recursive conflicts. When we get a line-level conflict in merge-recursive and print out the two sides in the conflict hunk header and footer we should use the standard extended SHA1 syntax to specify the specific blob, as this allows the user to copy and paste the line right into 'git show' to view the complete version. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- merge-recursive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/merge-recursive.c b/merge-recursive.c index ae7ae4cd2a..abebb950ab 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -649,8 +649,8 @@ static struct merge_file_info merge_file(struct diff_filespec *o, char *name1, *name2; int merge_status; - name1 = xstrdup(mkpath("%s/%s", branch1, a->path)); - name2 = xstrdup(mkpath("%s/%s", branch2, b->path)); + name1 = xstrdup(mkpath("%s:%s", branch1, a->path)); + name2 = xstrdup(mkpath("%s:%s", branch2, b->path)); fill_mm(o->sha1, &orig); fill_mm(a->sha1, &src1); From e0ec18192db8a5f80705a81dfaa1caa3e6c48c1a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 23 Dec 2006 03:44:47 -0500 Subject: [PATCH 20/20] Display 'theirs' branch name when possible in merge. Displaying the SHA1 of 'their' branch (the branch being merged into the current branch) is not nearly as friendly as just displaying the name of that branch, especially if that branch is already local to this repository. git-merge now sets the environment variable 'GITHEAD_%(sha1)=%(name)' for each argument it gets passed, making the actual input name that resolved to the commit '%(sha1)' easily available to the invoked merge strategy. git-merge-recursive makes use of these environment variables when they are available by using '%(name)' whenever it outputs the commit identification rather than '%(sha1)'. This is most obvious in the conflict hunks created by xdl_merge: $ git mege sideb~1 <<<<<<< HEAD:INSTALL Good! ======= Oops. >>>>>>> sideb~1:INSTALL [jc: adjusted a test script and a minor constness glitch.] Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-merge.sh | 2 ++ merge-recursive.c | 17 ++++++++++++++++- t/t6024-recursive-merge.sh | 6 +++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/git-merge.sh b/git-merge.sh index aec215e725..7dd0a11236 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -221,6 +221,8 @@ do remotehead=$(git-rev-parse --verify "$remote"^0 2>/dev/null) || die "$remote - not something we can merge" remoteheads="${remoteheads}$remotehead " + eval GITHEAD_$remotehead='"$remote"' + export GITHEAD_$remotehead done set x $remoteheads ; shift diff --git a/merge-recursive.c b/merge-recursive.c index abebb950ab..ca4f19e34d 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1263,6 +1263,18 @@ static struct commit *get_ref(const char *ref) return (struct commit *)object; } +static const char *better_branch_name(const char *branch) +{ + static char githead_env[8 + 40 + 1]; + char *name; + + if (strlen(branch) != 40) + return branch; + sprintf(githead_env, "GITHEAD_%s", branch); + name = getenv(githead_env); + return name ? name : branch; +} + int main(int argc, char *argv[]) { static const char *bases[2]; @@ -1293,11 +1305,14 @@ int main(int argc, char *argv[]) branch1 = argv[++i]; branch2 = argv[++i]; - printf("Merging %s with %s\n", branch1, branch2); h1 = get_ref(branch1); h2 = get_ref(branch2); + branch1 = better_branch_name(branch1); + branch2 = better_branch_name(branch2); + printf("Merging %s with %s\n", branch1, branch2); + if (bases_count == 1) { struct commit *ancestor = get_ref(bases[0]); clean = merge(h1, h2, branch1, branch2, 0, ancestor, &result); diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh index 964010e764..69b18f7d81 100644 --- a/t/t6024-recursive-merge.sh +++ b/t/t6024-recursive-merge.sh @@ -59,18 +59,18 @@ GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F test_expect_failure "combined merge conflicts" "git merge -m final G" cat > expect << EOF -<<<<<<< HEAD/a1 +<<<<<<< HEAD:a1 F ======= G ->>>>>>> 26f86b677eb03d4d956dbe108b29cb77061c1e73/a1 +>>>>>>> G:a1 EOF test_expect_success "result contains a conflict" "diff -u expect a1" git ls-files --stage > out cat > expect << EOF -100644 f16f906ab60483c100d1241dfc39868de9ec9fcb 1 a1 +100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1 a1 100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1 100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1 EOF