threads / patch / 10617

patchMake git-blame fail when working tree is needed and we're not in one

Subject: [PATCH] Make git-blame fail when working tree is needed and we're not in one

## tl;dr

7 messages between Nov 3, 2007 and Nov 4, 2007. Diffs are folded; open one to read it.

replies: 6people: 3as markdown or json

Mike Hommey· Nov 3, 2007, 12:22 UTC · lore

[PATCH] Delay pager setup in git blame

This avoids to launch the pager when git blame fails for any reason.
Signed-off-by: Mike Hommey <mh@glandium.org>
---
 builtin-blame.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Show changes to builtin-blame.c +3 −3
diff --git a/builtin-blame.c b/builtin-blame.c
index 8432b82..aedc294 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2215,9 +2215,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 			argv[unk++] = arg;
 	}
 
-	if (!incremental)
-		setup_pager();
-
 	if (!blame_move_score)
 		blame_move_score = BLAME_DEFAULT_MOVE_SCORE;
 	if (!blame_copy_score)
@@ -2411,6 +2408,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 
 	read_mailmap(&mailmap, ".mailmap", NULL);
 
+	if (!incremental)
+		setup_pager();
+
 	assign_blame(&sb, &revs, opt);
 
 	if (incremental)
-- 
1.5.3.5
Mike Hommey· Nov 3, 2007, 12:22 UTC · re: Mike Hommey · lore

[PATCH] Allow 'git blame rev path' to work on bare repository

While 'git blame rev -- path' works, 'git blame rev path' didn't.
Signed-off-by: Mike Hommey <mh@glandium.org>
---
 builtin-blame.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
Show changes to builtin-blame.c +0 −4
diff --git a/builtin-blame.c b/builtin-blame.c
index aedc294..141287e 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2294,10 +2294,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 			}
 			else if (i != argc - 1)
 				usage(blame_usage); /* garbage at end */
-
-			if (!has_path_in_work_tree(path))
-				die("cannot stat path %s: %s",
-				    path, strerror(errno));
 		}
 	}
 
-- 
1.5.3.5
Mike Hommey· Nov 3, 2007, 12:22 UTC · re: Mike Hommey · lore
Signed-off-by: Mike Hommey <mh@glandium.org>
---
 builtin-blame.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to builtin-blame.c +1 −0
diff --git a/builtin-blame.c b/builtin-blame.c
index 141287e..500ae77 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2338,6 +2338,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 		 * do not default to HEAD, but use the working tree
 		 * or "--contents".
 		 */
+		setup_work_tree();
 		sb.final = fake_working_tree_commit(path, contents_from);
 		add_pending_object(&revs, &(sb.final->object), ":");
 	}
-- 
1.5.3.5
Mike Hommey· Nov 3, 2007, 12:30 UTC · re: Mike Hommey · lore

Re: [PATCH] Make git-blame fail when working tree is needed and we're not in one

Oops, I forgot -n to format-patch. Wasn't there a proposal to have -n automatically set when outputing several patches ?

Mike
Andreas Ericsson· Nov 3, 2007, 15:01 UTC · re: Mike Hommey · lore

Re: [PATCH] Make git-blame fail when working tree is needed and we're not in one

Mike Hommey wrote:
> Oops, I forgot -n to format-patch. Wasn't there a proposal to have -n
> automatically set when outputing several patches ?
> 

No. There was a patch to skip numbering when only one patch was created. I suppose a different implementation of that patch could make the default to number when multiple patches are created but not when a single one is.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Junio C Hamano· Nov 4, 2007, 05:21 UTC · re: Mike Hommey · lore

Re: [PATCH] Allow 'git blame rev path' to work on bare repository

Mike Hommey <mh@glandium.org> writes:
Show 22 quoted lines
> While 'git blame rev -- path' works, 'git blame rev path' didn't.
>
> Signed-off-by: Mike Hommey <mh@glandium.org>
> ---
>  builtin-blame.c |    4 ----
>  1 files changed, 0 insertions(+), 4 deletions(-)
>
> diff --git a/builtin-blame.c b/builtin-blame.c
> index aedc294..141287e 100644
> --- a/builtin-blame.c
> +++ b/builtin-blame.c
> @@ -2294,10 +2294,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
>  			}
>  			else if (i != argc - 1)
>  				usage(blame_usage); /* garbage at end */
> -
> -			if (!has_path_in_work_tree(path))
> -				die("cannot stat path %s: %s",
> -				    path, strerror(errno));
>  		}
>  	}
>  

Sorry but a NAK; at least limit the removal of the test only to a bare repository case.

Mike Hommey· Nov 4, 2007, 08:26 UTC · re: Junio C Hamano · lore

Re: [PATCH] Allow 'git blame rev path' to work on bare repository

On Sat, Nov 03, 2007 at 10:21:53PM -0700, Junio C Hamano wrote:
Show 27 quoted lines
> Mike Hommey <mh@glandium.org> writes:
> 
> > While 'git blame rev -- path' works, 'git blame rev path' didn't.
> >
> > Signed-off-by: Mike Hommey <mh@glandium.org>
> > ---
> >  builtin-blame.c |    4 ----
> >  1 files changed, 0 insertions(+), 4 deletions(-)
> >
> > diff --git a/builtin-blame.c b/builtin-blame.c
> > index aedc294..141287e 100644
> > --- a/builtin-blame.c
> > +++ b/builtin-blame.c
> > @@ -2294,10 +2294,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
> >  			}
> >  			else if (i != argc - 1)
> >  				usage(blame_usage); /* garbage at end */
> > -
> > -			if (!has_path_in_work_tree(path))
> > -				die("cannot stat path %s: %s",
> > -				    path, strerror(errno));
> >  		}
> >  	}
> >  
> 
> Sorry but a NAK; at least limit the removal of the test only to a bare
> repository case.

I fail to see why this test is necessary here. The lack of file in the working tree is caught in fake_working_tree_commit() anyways.

Mike

← back to recent threads