From 56d99c67d1ad95326902f3a739ab2a3c7bb2d6fe Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 19 May 2007 23:35:21 +0200 Subject: Update bash completion to ignore some more plumbing commands [sp: Modified Jonas' original patch to keep checkout-index as a a valid completion.] Signed-off-by: Jonas Fonseca Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 46356e8a2..35b1ff915 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -262,6 +262,7 @@ __git_commands () applypatch) : ask gittus;; archimport) : import;; cat-file) : plumbing;; + check-attr) : plumbing;; check-ref-format) : plumbing;; commit-tree) : plumbing;; convert-objects) : plumbing;; @@ -271,8 +272,10 @@ __git_commands () daemon) : daemon;; fast-import) : import;; fsck-objects) : plumbing;; + fetch--tool) : plumbing;; fetch-pack) : plumbing;; fmt-merge-msg) : plumbing;; + for-each-ref) : plumbing;; hash-object) : plumbing;; http-*) : transport;; index-pack) : plumbing;; -- cgit v1.2.1 From 5cfb4fe525034b758ca39a32d05cc8b2a53d2a13 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:01:02 -0400 Subject: Hide the plumbing diff-{files,index,tree} from bash completion The diff-* programs are meant to be plumbing for the diff frontend; most end users aren't invoking these commands directly. Consequently we should avoid showing them as possible completions. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 35b1ff915..994474502 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -270,6 +270,9 @@ __git_commands () cvsimport) : import;; cvsserver) : daemon;; daemon) : daemon;; + diff-files) : plumbing;; + diff-index) : plumbing;; + diff-tree) : plumbing;; fast-import) : import;; fsck-objects) : plumbing;; fetch--tool) : plumbing;; @@ -950,7 +953,6 @@ _git () commit) _git_commit ;; config) _git_config ;; diff) _git_diff ;; - diff-tree) _git_diff_tree ;; fetch) _git_fetch ;; format-patch) _git_format_patch ;; gc) _git_gc ;; @@ -995,7 +997,6 @@ complete -o default -o nospace -F _git_cherry git-cherry complete -o default -o nospace -F _git_cherry_pick git-cherry-pick complete -o default -o nospace -F _git_commit git-commit complete -o default -o nospace -F _git_diff git-diff -complete -o default -o nospace -F _git_diff_tree git-diff-tree complete -o default -o nospace -F _git_fetch git-fetch complete -o default -o nospace -F _git_format_patch git-format-patch complete -o default -o nospace -F _git_gc git-gc @@ -1026,7 +1027,6 @@ complete -o default -o nospace -F _git git.exe complete -o default -o nospace -F _git_branch git-branch.exe complete -o default -o nospace -F _git_cherry git-cherry.exe complete -o default -o nospace -F _git_diff git-diff.exe -complete -o default -o nospace -F _git_diff_tree git-diff-tree.exe complete -o default -o nospace -F _git_format_patch git-format-patch.exe complete -o default -o nospace -F _git_log git-log.exe complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe -- cgit v1.2.1 From 1fd6bec9bcb2d7fc710a9866bd53ea52f43d4428 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:25:34 -0400 Subject: Teach bash completion about git-shortlog We've had completion for git-log for quite some time, but just today I noticed we don't have it for the new builtin shortlog that runs git-log internally. This is indeed a handy thing to have completion for, especially when your branch names are of the Very-Very-Long-and-Hard/To-Type/Variety/That-Some-Use. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 994474502..d75f47a1a 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -896,6 +896,26 @@ _git_reset () __gitcomp "$(__git_refs)" } +_git_shortlog () +{ + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + --*) + __gitcomp " + --max-count= --max-age= --since= --after= + --min-age= --before= --until= + --no-merges + --author= --committer= --grep= + --all-match + --not --all + --numbered --summary + " + return + ;; + esac + __git_complete_revlist +} + _git_show () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -967,6 +987,7 @@ _git () rebase) _git_rebase ;; remote) _git_remote ;; reset) _git_reset ;; + shortlog) _git_shortlog ;; show) _git_show ;; show-branch) _git_log ;; whatchanged) _git_log ;; @@ -1012,6 +1033,7 @@ complete -o default -o nospace -F _git_rebase git-rebase complete -o default -o nospace -F _git_config git-config complete -o default -o nospace -F _git_remote git-remote complete -o default -o nospace -F _git_reset git-reset +complete -o default -o nospace -F _git_shortlog git-shortlog complete -o default -o nospace -F _git_show git-show complete -o default -o nospace -F _git_log git-show-branch complete -o default -o nospace -F _git_log git-whatchanged @@ -1034,6 +1056,7 @@ complete -o default -o nospace -F _git_merge_base git-merge-base.exe complete -o default -o nospace -F _git_name_rev git-name-rev.exe complete -o default -o nospace -F _git_push git-push.exe complete -o default -o nospace -F _git_config git-config +complete -o default -o nospace -F _git_shortlog git-shortlog.exe complete -o default -o nospace -F _git_show git-show.exe complete -o default -o nospace -F _git_log git-show-branch.exe complete -o default -o nospace -F _git_log git-whatchanged.exe -- cgit v1.2.1 From bfbd131f52ff8373ffabbb30f275b4af8213f5f0 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:26:58 -0400 Subject: Remove a duplicate --not option in bash completion This was just me being silly; I put the --not option into the completion list twice. There's no duplicates shown in the shell as the shell removes them before showing them to the user. But we really don't need the duplicates in the source script either. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index d75f47a1a..24b18183f 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -579,7 +579,7 @@ _git_log () __gitcomp " --max-count= --max-age= --since= --after= --min-age= --before= --until= - --root --not --topo-order --date-order + --root --topo-order --date-order --no-merges --abbrev-commit --abbrev= --relative-date -- cgit v1.2.1 From c70680ce7cec72a465468c223d43c08f5254d31f Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:36:46 -0400 Subject: Update bash completion header documentation 1) Added a note about supporting the long options for most commands, as we have been doing so for quite some time. 2) Include a notice that these routines are covered by the GPL, as that may not be obvious, even though they are distributed as part of the core Git distribution. 3) Added a short section on how to send patches to the routines, and to whom they should get sent to. Currently that is me, as I am the active maintainer. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 24b18183f..48ba3f8e8 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1,8 +1,9 @@ # # bash completion support for core Git. # -# Copyright (C) 2006,2007 Shawn Pearce +# Copyright (C) 2006,2007 Shawn O. Pearce # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). +# Distributed under the GNU General Public License, version 2.0. # # The contained completion routines provide support for completing: # @@ -11,6 +12,7 @@ # *) .git/remotes file names # *) git 'subcommands' # *) tree paths within 'ref:path/to/file' expressions +# *) common --long-options # # To use these routines: # @@ -31,6 +33,17 @@ # are currently in a git repository. The %s token will be # the name of the current branch. # +# To submit patches: +# +# *) Read Documentation/SubmittingPatches +# *) Send all patches to the current maintainer: +# +# "Shawn O. Pearce" +# +# *) Always CC the Git mailing list: +# +# git@vger.kernel.org +# __gitdir () { -- cgit v1.2.1 From fb72759b7de504f077250fd5bd557e3b9e2a5682 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:46:49 -0400 Subject: Teach bash completion about 'git remote update' Recently the git-remote command grew an update subcommand, which can be used to execute git-fetch across multiple repositories in a single step. These can be configured with the 'remotes.*' configuration options, so we can offer completion for any name that matches and appears to be useful to git-remote update. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 48ba3f8e8..d6252068c 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -877,13 +877,13 @@ _git_remote () while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in - add|show|prune) command="$i"; break ;; + add|show|prune|update) command="$i"; break ;; esac c=$((++c)) done if [ $c -eq $COMP_CWORD -a -z "$command" ]; then - __gitcomp "add show prune" + __gitcomp "add show prune update" return fi @@ -891,6 +891,18 @@ _git_remote () show|prune) __gitcomp "$(__git_remotes)" ;; + update) + local i c='' IFS=$'\n' + for i in $(git --git-dir="$(__gitdir)" config --list); do + case "$i" in + remotes.*) + i="${i#remotes.}" + c="$c ${i/=*/}" + ;; + esac + done + __gitcomp "$c" + ;; *) COMPREPLY=() ;; -- cgit v1.2.1 From 8f87fae6459b7d5b8058691911f1c18c59a5dcbd Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 01:51:30 -0400 Subject: Teach bash completion about recent log long options (Somewhat) recently git-log learned about --reverse (to show commits in the opposite order) and a looong time ago I think it learned about --raw (to show the raw diff, rather than a unified diff). These are both useful options, so we should make them easy for the user to complete. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index d6252068c..0b8cb5f0e 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -592,13 +592,13 @@ _git_log () __gitcomp " --max-count= --max-age= --since= --after= --min-age= --before= --until= - --root --topo-order --date-order + --root --topo-order --date-order --reverse --no-merges --abbrev-commit --abbrev= --relative-date --author= --committer= --grep= --all-match - --pretty= --name-status --name-only + --pretty= --name-status --name-only --raw --not --all " return -- cgit v1.2.1 From 12977705b3da7eb63cdfd890f838b971e8d81485 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 May 2007 02:07:45 -0400 Subject: Update bash completion for git-config options A few new configuration options grew out of the woodwork during the 1.5.2 series. Most of these are pretty easy to support a completion of, so we do so. I wanted to also add completion support for the part of merge..name but to do that we have to look at all of the .gitattributes files and guess what the unique set of strings would be. Since this appears to be non-trivial I'm punting on it at this time. Signed-off-by: Shawn O. Pearce --- contrib/completion/git-completion.bash | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 0b8cb5f0e..9e72f0f7b 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -764,9 +764,11 @@ _git_config () case "$cur" in --*) __gitcomp " - --global --list --replace-all + --global --system + --list --replace-all --get --get-all --get-regexp --add --unset --unset-all + --remove-section --rename-section " return ;; @@ -785,7 +787,10 @@ _git_config () remote.*.*) local pfx="${cur%.*}." cur="${cur##*.}" - __gitcomp "url fetch push" "$pfx" "$cur" + __gitcomp " + url fetch push skipDefaultUpdate + receivepack uploadpack tagopt + " "$pfx" "$cur" return ;; remote.*) @@ -835,6 +840,9 @@ _git_config () format.headers gitcvs.enabled gitcvs.logfile + gitcvs.allbinary + gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass + gc.packrefs gc.reflogexpire gc.reflogexpireunreachable gc.rerereresolved @@ -851,9 +859,11 @@ _git_config () i18n.commitEncoding i18n.logOutputEncoding log.showroot + merge.tool merge.summary merge.verbosity pack.window + pack.depth pull.octopus pull.twohead repack.useDeltaBaseOffset -- cgit v1.2.1 From c075aea5da6c35edfe86da7d3edced67cdb009c8 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 24 May 2007 12:20:42 -0700 Subject: name-rev: tolerate clock skew in committer dates In git.git repository, "git-name-rev v1.3.0~158" cannot name the rev, while adjacent revs can be named. This was because it gives up traversal from the tips of existing refs as soon as it sees a commit that has older commit timestamp than what is being named. This is usually a good heuristics, but v1.3.0~158 has a slightly older commit timestamp than v1.3.0~157 (i.e. it's child), as these two were made in a separate repostiory (in fact, in a different continent). This adds a hardcoded slop value (1 day) to the cut-off heuristics to work this kind of problem around. The current algorithm essentially runs around from the available tips down to ancient commits and names every single rev available that are newer than cut-off date, so a single day slop would not add that much overhead in repositories with long enough history where the performance of name-rev matters. I think the algorithm could be made a bit smarter by deepening the graph on demand as a new commit is asked to be named (this would require rewriting of name_rev() function not to recurse itself but use a traversal list like revision.c traverser does), but that would be a separate issue. Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin-name-rev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/builtin-name-rev.c b/builtin-name-rev.c index ef1638590..2d94eaaa6 100644 --- a/builtin-name-rev.c +++ b/builtin-name-rev.c @@ -4,6 +4,8 @@ #include "tag.h" #include "refs.h" +#define CUTOFF_DATE_SLOP 86400 /* one day */ + static const char name_rev_usage[] = "git-name-rev [--tags | --refs=] ( --all | --stdin | committish [committish...] )\n"; @@ -208,6 +210,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) add_object_array((struct object *)commit, *argv, &revs); } + if (cutoff) + cutoff = cutoff - CUTOFF_DATE_SLOP; for_each_ref(name_ref, &data); if (transform_stdin) { -- cgit v1.2.1 From 0b1f113075aafb0c91a406d984d0152e55c981da Mon Sep 17 00:00:00 2001 From: Carlos Rica Date: Fri, 25 May 2007 03:46:22 +0200 Subject: fix memory leak in parse_object when check_sha1_signature fails When check_sha1_signature fails, program is not terminated: it prints an error message and returns NULL, so the buffer returned by read_sha1_file should be freed before. Signed-off-by: Carlos Rica Signed-off-by: Junio C Hamano --- object.c | 1 + 1 file changed, 1 insertion(+) diff --git a/object.c b/object.c index 78a44a6ef..ccd7dd796 100644 --- a/object.c +++ b/object.c @@ -185,6 +185,7 @@ struct object *parse_object(const unsigned char *sha1) if (buffer) { struct object *obj; if (check_sha1_signature(sha1, buffer, size, typename(type)) < 0) { + free(buffer); error("sha1 mismatch %s\n", sha1_to_hex(sha1)); return NULL; } -- cgit v1.2.1