From 3af1cae469555485cd3ef003aa2a55bd2a4f544f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 8 Jun 2009 23:26:44 -0700 Subject: [PATCH 1/7] show-branch: fix segfault when showbranch.default exists When running "git show-branch" without any parameter in a repository that has showbranch.default defined, we used to rely on the fact that our handcrafted option parsing loop never looked at av[0]. The array of default strings had the first real command line argument in default_arg[0], but the option parser wanted to look at the array starting at av[1], so we assigned the address of -1th element to av to force the loop start working from default_arg[0]. This no longer worked since 5734365 (show-branch: migrate to parse-options API, 2009-05-21), as parse_options_start() saved the incoming &av[0] in its ctx->out and later in parse_options_end() it did memmove to ctx->out (with ctx->cpidx == 0), overwriting the memory before default_arg[] array. I am not sure if this is a bug in parse_options(), or a bug in the caller, and tonight I do not have enough concentration to figure out which. In any case, this patch works the issue around. Signed-off-by: Junio C Hamano --- builtin-show-branch.c | 14 +++++++++++--- t/t3202-show-branch-octopus.sh | 8 ++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/builtin-show-branch.c b/builtin-show-branch.c index b1affd2ffb..5d85ab0cae 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -565,7 +565,15 @@ static int git_show_branch_config(const char *var, const char *value, void *cb) if (!strcmp(var, "showbranch.default")) { if (!value) return config_error_nonbool(var); - if (default_alloc <= default_num + 1) { + /* + * default_arg is now passed to parse_options(), so we need to + * mimick the real argv a bit better. + */ + if (!default_num) { + default_alloc = 20; + default_arg = xcalloc(default_alloc, sizeof(*default_arg)); + default_arg[default_num++] = "show-branch"; + } else if (default_alloc <= default_num + 1) { default_alloc = default_alloc * 3 / 2 + 20; default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc); } @@ -693,8 +701,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) /* If nothing is specified, try the default first */ if (ac == 1 && default_num) { - ac = default_num + 1; - av = default_arg - 1; /* ick; we would not address av[0] */ + ac = default_num; + av = default_arg; } ac = parse_options(ac, av, builtin_show_branch_options, diff --git a/t/t3202-show-branch-octopus.sh b/t/t3202-show-branch-octopus.sh index 7fe4a6ecb0..0a5d5e669f 100755 --- a/t/t3202-show-branch-octopus.sh +++ b/t/t3202-show-branch-octopus.sh @@ -56,4 +56,12 @@ test_expect_success 'show-branch with more than 8 branches' ' ' +test_expect_success 'show-branch with showbranch.default' ' + for i in $numbers; do + git config --add showbranch.default branch$i + done && + git show-branch >out && + test_cmp expect out +' + test_done From 4973aa2286110fcedc0e8ff0da57c10509fb1a65 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 5 Oct 2009 12:03:25 -0700 Subject: [PATCH 2/7] git-pull: dead code removal Back when a74b170 (git-pull: disallow implicit merging to detached HEAD, 2007-01-15) added this check, $? referred to the error status of reading HEAD as a symbolic-ref; but cd67e4d (Teach 'git pull' about --rebase, 2007-11-28) moved the command away from where the check is, and nobody noticed the breakage. Ever since, $? has always been 0 (tr at the end of the pipe to find merge_head never fails) and other case arms were never reached. These days, error_on_no_merge_candidates function is prepared to handle a detached HEAD case, which was what the code this patch removes used to handle. Signed-off-by: Junio C Hamano --- git-pull.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/git-pull.sh b/git-pull.sh index edf3ce33bf..66d73eb59d 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -182,14 +182,7 @@ merge_head=$(sed -e '/ not-for-merge /d' \ case "$merge_head" in '') - case $? in - 0) error_on_no_merge_candidates "$@";; - 1) echo >&2 "You are not currently on a branch; you must explicitly" - echo >&2 "specify which branch you wish to merge:" - echo >&2 " git pull " - exit 1;; - *) exit $?;; - esac + error_on_no_merge_candidates "$@" ;; ?*' '?*) if test -z "$orig_head" From f73b3af3f047bcc503e8860c2075052309627e60 Mon Sep 17 00:00:00 2001 From: Stefan Naewe Date: Wed, 7 Oct 2009 14:14:24 +0200 Subject: [PATCH 3/7] README: git lives at http://git-scm.com these days Signed-off-by: Stefan Naewe Signed-off-by: Junio C Hamano --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index c932ab3105..67cfeb2016 100644 --- a/README +++ b/README @@ -37,7 +37,7 @@ CVS users may also want to read Documentation/gitcvs-migration.txt ("man gitcvs-migration" or "git help cvs-migration" if git is installed). -Many Git online resources are accessible from http://git.or.cz/ +Many Git online resources are accessible from http://git-scm.com/ including full documentation and Git related tools. The user discussion and development of Git take place on the Git From 1cd749cc0722533bd1849f491ec9ab19e17232e1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 28 Sep 2009 23:40:09 -0700 Subject: [PATCH 4/7] fast-import.c::validate_raw_date(): really validate the value When reading the "raw format" timestamp from the input stream, make sure that the timezone offset is a reasonable value by imitating 7122f82 (date.c: improve guess between timezone offset and year., 2006-06-08). We _might_ want to also check if the timestamp itself is reasonable, but that is left for a separate commit. Signed-off-by: Junio C Hamano --- fast-import.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fast-import.c b/fast-import.c index 7ef9865aa6..6faaaacb68 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1744,10 +1744,12 @@ static int validate_raw_date(const char *src, char *result, int maxlen) { const char *orig_src = src; char *endp; + unsigned long num; errno = 0; - strtoul(src, &endp, 10); + num = strtoul(src, &endp, 10); + /* NEEDSWORK: perhaps check for reasonable values? */ if (errno || endp == src || *endp != ' ') return -1; @@ -1755,8 +1757,9 @@ static int validate_raw_date(const char *src, char *result, int maxlen) if (*src != '-' && *src != '+') return -1; - strtoul(src + 1, &endp, 10); - if (errno || endp == src || *endp || (endp - orig_src) >= maxlen) + num = strtoul(src + 1, &endp, 10); + if (errno || endp == src + 1 || *endp || (endp - orig_src) >= maxlen || + 1400 < num) return -1; strcpy(result, orig_src); From 294ac78d145d236447ac41774ee55af436e178a0 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Tue, 6 Oct 2009 20:02:22 -0500 Subject: [PATCH 5/7] Makefile: enable THREADED_DELTA_SEARCH on SunOS Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 12defd4c97..dd3d5203f9 100644 --- a/Makefile +++ b/Makefile @@ -734,6 +734,7 @@ ifeq ($(uname_S),SunOS) NO_MKSTEMPS = YesPlease NO_REGEX = YesPlease NO_EXTERNAL_GREP = YesPlease + THREADED_DELTA_SEARCH = YesPlease ifeq ($(uname_R),5.7) NEEDS_RESOLV = YesPlease NO_IPV6 = YesPlease From af4e9e8c87d3e73056c4758279c4c8462fe5e573 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Wed, 7 Oct 2009 01:48:50 -0700 Subject: [PATCH 6/7] completion: update am, commit, and log git am learned --scissors, git commit learned --dry-run and git log learned --decorate=long|short recently. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 2c2a0d4614..daccbcc33e 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -668,7 +668,7 @@ _git_am () --3way --committer-date-is-author-date --ignore-date --ignore-whitespace --ignore-space-change --interactive --keep --no-utf8 --signoff --utf8 - --whitespace= + --whitespace= --scissors " return esac @@ -894,6 +894,7 @@ _git_commit () __gitcomp " --all --author= --signoff --verify --no-verify --edit --amend --include --only --interactive + --dry-run " return esac @@ -1179,6 +1180,10 @@ _git_log () __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" return ;; + --decorate=*) + __gitcomp "long short" "" "${cur##--decorate=}" + return + ;; --*) __gitcomp " $__git_log_common_options @@ -1191,7 +1196,7 @@ _git_log () --pretty= --format= --oneline --cherry-pick --graph - --decorate + --decorate --decorate= --walk-reflogs --parents --children $merge From 8fd2cfa7accd6b8f877014bf3e4bf8547b8e0d2a Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Wed, 7 Oct 2009 01:48:51 -0700 Subject: [PATCH 7/7] completion: add dirstat and friends to diff options Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index daccbcc33e..88b1b3c7a0 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -927,6 +927,8 @@ __git_diff_common_options="--stat --numstat --shortstat --summary --inter-hunk-context= --patience --raw + --dirstat --dirstat= --dirstat-by-file + --dirstat-by-file= --cumulative " _git_diff ()