[PATCH/RFC] archive: allow archiving of reachable sha1
Remotely specify a tree-ish by a sha1 is now valid even if uploadarchive.allowunreachable is false only if this sha1 is reachable from a branch or a tag reference. We consider those last one to be public. Signed-off-by: Nicolas Cornu --- Do you think this patch is too much "computationnally expensive"? Maybe we need an option to disable such a a feature. If we want an option I think it's better to have an option disabling this feature. This way server will accept such archiving by default. Documentation/git-upload-archive.txt | 19 ++- archive.c| 15 +-- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Documentation/git-upload-archive.txt b/Documentation/git-upload-archive.txt index fba0f1c..59d9b65 100644 --- a/Documentation/git-upload-archive.txt +++ b/Documentation/git-upload-archive.txt @@ -26,25 +26,18 @@ SECURITY In order to protect the privacy of objects that have been removed from history but may not yet have been pruned, `git-upload-archive` avoids serving archives for commits and trees that are not reachable from the -repository's refs. However, because calculating object reachability is -computationally expensive, `git-upload-archive` implements a stricter -but easier-to-check set of rules: +repository's refs. `git-upload-archive` implements a stricter but +easier-to-check set of rules: 1. Clients may request a commit or tree that is pointed to directly by - a ref. E.g., `git archive --remote=origin v1.0`. + a ref or is an ancestor of a branch or tag ref. + E.g., `git archive --remote=origin v1.0`. 2. Clients may request a sub-tree within a commit or tree using the `ref:path` syntax. E.g., `git archive --remote=origin v1.0:Documentation`. - 3. Clients may _not_ use other sha1 expressions, even if the end - result is reachable. E.g., neither a relative commit like `master^` - nor a literal sha1 like `abcd1234` is allowed, even if the result - is reachable from the refs. - -Note that rule 3 disallows many cases that do not have any privacy -implications. These rules are subject to change in future versions of -git, and the server accessed by `git archive --remote` may or may not -follow these exact rules. +These rules are subject to change in future versions of git, and the server +accessed by `git archive --remote` may or may not follow these exact rules. If the config option `uploadArchive.allowUnreachable` is true, these rules are ignored, and clients may use arbitrary sha1 expressions. diff --git a/archive.c b/archive.c index 42df974..d99c195 100644 --- a/archive.c +++ b/archive.c @@ -347,6 +347,12 @@ static void parse_pathspec_arg(const char **pathspec, } } +static int is_reachable(const char *refname, const struct object_id *oid, int flags, void *cb_data) +{ + const unsigned char *sha1 = (unsigned char *)cb_data; + return in_merge_bases(lookup_commit(sha1), lookup_commit(oid->hash)); +} + static void parse_treeish_arg(const char **argv, struct archiver_args *ar_args, const char *prefix, int remote) @@ -364,8 +370,13 @@ static void parse_treeish_arg(const char **argv, const char *colon = strchrnul(name, ':'); int refnamelen = colon - name; - if (!dwim_ref(name, refnamelen, oid.hash, &ref)) - die("no such ref: %.*s", refnamelen, name); + if (!dwim_ref(name, refnamelen, oid.hash, &ref)) { + if (get_sha1(name, oid.hash)) + die("Not a valid object name"); + if (!for_each_branch_ref(&is_reachable, oid.hash) && + !for_each_tag_ref(&is_reachable, oid.hash)) + die("no such ref: %.*s", refnamelen, name); + } free(ref); } -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history
2013/10/30 Marc Branchaud : > On 13-10-30 08:47 AM, Nicolas Cornu wrote: >> This is useful on all our repos, every times, as we put a tag per day. >> If the HEAD didn't move during 150 days, we got 150 tags. >> So, it depends, maybe can I put it as an option in Edit > Preferences? > > Eek, even with a scrollbar, 150 tags seems like a lot to pan over. Now, it works pretty well and is easier than mouse middle-click which acts strangely for me. > > I've often thought it would be good for gitk to combine multiple ref names > into some kind of dropdown or view-on-hover list. (I don't know anything > about Tcl/Tk, so I don't know what's feasible.) So if a commit has more than > a couple of branches (and/or tags), only show the first branch name along > with a glyph indicating that there are more, and let the user click on (or > hover over) that glyph to see all the branches (or tags -- that is, still > keep the tags and branches displayed separately). It doesn't change that if you got 150 tags, when you will show them up, you will need to scroll. > > M. > -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history
This is useful on all our repos, every times, as we put a tag per day. If the HEAD didn't move during 150 days, we got 150 tags. So, it depends, maybe can I put it as an option in Edit > Preferences? 2013/10/30 Johannes Sixt : > Am 10/30/2013 11:58, schrieb Nicolas Cornu: >> This scrollbar is not optional and is useful if there is a lot of tags or >> branches. > > If this is the "only" case where the scrollbar is useful, i.e., it would > be handy only once every other week, then it is better to remember that > you can pan around in the window by moving the mouse with the middle mouse > button held down. Vertical screen estate in the commit history pane is too > precious to waste for a scrollbar that is useless most of the time. > > -- Hannes -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] gitk: Add a horizontal scrollbar for commit history
This scrollbar is not optional and is useful if there is a lot of tags or branches. Signed-off-by: Nicolas Cornu --- gitk | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gitk b/gitk index 5cd00d8..62563b1 100755 --- a/gitk +++ b/gitk @@ -2120,11 +2120,17 @@ proc makewindow {} { # create three canvases set cscroll .tf.histframe.csb set canv .tf.histframe.pwclist.canv +set cscrollhl .tf.histframe.pwclist.canv.csb canvas $canv \ -selectbackground $selectbgcolor \ -background $bgcolor -bd 0 \ - -yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll" + -yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll" \ + -xscrollcommand "scrollcanv $cscrollhl" .tf.histframe.pwclist add $canv +${NS}::scrollbar $cscrollhl -command {$canv xview} -orient horizontal +if {!$use_ttk} {$cscrollhl configure -highlightthickness 0} +pack $cscrollhl -fill x -side bottom + set canv2 .tf.histframe.pwclist.canv2 canvas $canv2 \ -selectbackground $selectbgcolor \ -- 1.8.4.2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Add a scrollbar for commit history in gitk
>From b3570290bd761a1bf952ea491fa62b123231fe61 Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Tue, 29 Oct 2013 14:51:29 +0100 Subject: [PATCH] Add a scrollbar for commit history in gitk --- gitk-git/gitk | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gitk-git/gitk b/gitk-git/gitk index d6f5e07..e517253 100755 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -2124,11 +2124,17 @@ proc makewindow {} { # create three canvases set cscroll .tf.histframe.csb set canv .tf.histframe.pwclist.canv +set cscrollhl .tf.histframe.pwclist.canv.csb canvas $canv \ -selectbackground $selectbgcolor \ -background $bgcolor -bd 0 \ --yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll" +-yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll" \ +-xscrollcommand "scrollcanv $cscrollhl" .tf.histframe.pwclist add $canv +${NS}::scrollbar $cscrollhl -command {$canv xview} -orient horizontal +if {!$use_ttk} {$cscrollhl configure -highlightthickness 0} +pack $cscrollhl -fill x -side bottom + set canv2 .tf.histframe.pwclist.canv2 canvas $canv2 \ -selectbackground $selectbgcolor \ -- 1.8.4.2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Add option --no-tags
>From 1cbc2c49454581a67cce09ada1386dac4ffa2828 Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Tue, 29 Oct 2013 11:31:10 +0100 Subject: [PATCH] Add option --no-tags --- gitk-git/gitk | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gitk-git/gitk b/gitk-git/gitk index 5cd00d8..d6f5e07 100755 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -156,7 +156,7 @@ proc unmerged_files {files} { proc parseviewargs {n arglist} { global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env -global worddiff git_version +global worddiff git_version no_tags set vdatemode($n) 0 set vmergeonly($n) 0 @@ -167,6 +167,7 @@ proc parseviewargs {n arglist} { set origargs $arglist set allknown 1 set filtered 0 +set no_tags 0 set i -1 foreach arg $arglist { incr i @@ -183,6 +184,9 @@ proc parseviewargs {n arglist} { set origargs [lreplace $origargs $i $i] incr i -1 } + "--no-tags" { +set no_tags 1 + } "-[puabwcrRBMC]" - "--no-renames" - "--full-index" - "--binary" - "--abbrev=*" - "--find-copies-harder" - "-l*" - "--ext-diff" - "--no-ext-diff" - @@ -6394,13 +6398,16 @@ proc drawtags {id x xt y1} { global headbgcolor headfgcolor headoutlinecolor remotebgcolor global tagbgcolor tagfgcolor tagoutlinecolor global reflinecolor +global no_tags set marks {} set ntags 0 set nheads 0 if {[info exists idtags($id)]} { -set marks $idtags($id) -set ntags [llength $marks] + if {$no_tags < 1} { +set marks $idtags($id) +set ntags [llength $marks] + } } if {[info exists idheads($id)]} { set marks [concat $marks $idheads($id)] -- 1.8.4.2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html