threads / patch / 6237

patch, 2 partsRe: [PATCH 1/2] Suggest use of "git add file1 file2" when there is nothing to commit.

Subject: Re: [PATCH 1/2] Suggest use of "git add file1 file2" when there is nothing to commit.

## tl;dr

26 messages between Dec 16, 2006 and Jan 11, 2007. Diffs are folded; open one to read it.

replies: 25people: 5as markdown or json

Shawn O. Pearce· Dec 16, 2006, 02:53 UTC · lore

[PATCH 1/2] Suggest use of "git add file1 file2" when there is nothing to commit.

If a user modifies files and runs 'git commit' (without the very useful -a option) and they have not yet updated the index they are probably coming from another SCM-like tool which would perform the same as 'git commit -a' in this case. Showing the user their current status and a final line of "nothing to commit" is not very reassuring, as the user might believe that Git did not recognize their files were modified.

Instead we can suggest as part of the 'nothing to commit' message that the user invoke 'git add' to add files to their next commit.

Suggested by Andy Parkins' Git 'niggles' list (<200612132237.10051.andyparkins@gmail.com>).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 git-commit.sh |    2 +-
 wt-status.c   |   11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)
Show changes to 2 files +7 −6

git-commit.sh, wt-status.c

diff --git a/git-commit.sh b/git-commit.sh
index 05828bb..2672def 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -515,7 +515,7 @@ then
 	current="$(git-rev-parse --verify HEAD)"
 else
 	if [ -z "$(git-ls-files)" ]; then
-		echo >&2 Nothing to commit
+		echo >&2 'nothing to commit (use "git add file1 file2" to include for commit)'
 		exit 1
 	fi
 	PARENTS=""
diff --git a/wt-status.c b/wt-status.c
index 6e9414d..2173d4f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -15,6 +15,7 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
 	"\033[31m", /* WT_STATUS_CHANGED: red */
 	"\033[31m", /* WT_STATUS_UNTRACKED: red */
 };
+static const char* use_add_msg = "use \"git add file1 file2\" to include for commit";
 
 static int parse_status_slot(const char *var, int offset)
 {
@@ -162,8 +163,7 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
 {
 	int i;
 	if (q->nr)
-		wt_status_print_header("Changed but not updated",
-				"use git-add on files to include for commit");
+		wt_status_print_header("Changed but not updated", use_add_msg);
 	for (i = 0; i < q->nr; i++)
 		wt_status_print_filepair(WT_STATUS_CHANGED, q->queue[i]);
 	if (q->nr)
@@ -249,8 +249,7 @@ static void wt_status_print_untracked(const struct wt_status *s)
 				continue;
 		}
 		if (!shown_header) {
-			wt_status_print_header("Untracked files",
-				"use \"git add\" to add to commit");
+			wt_status_print_header("Untracked files", use_add_msg);
 			shown_header = 1;
 		}
 		color_printf(color(WT_STATUS_HEADER), "#\t");
@@ -292,7 +291,9 @@ void wt_status_print(struct wt_status *s)
 	if (s->verbose && !s->is_initial)
 		wt_status_print_verbose(s);
 	if (!s->commitable)
-		printf("%s\n", s->amend ? "# No changes" : "nothing to commit");
+		printf("%s (%s)\n",
+			s->amend ? "# No changes" : "nothing to commit",
+			use_add_msg);
 }
 
 int git_status_config(const char *k, const char *v)
-- 
1.4.4.2.g053a
Michael Loeffler· Jan 5, 2007, 20:44 UTC · re: Shawn O. Pearce · lore
Hi,

Am Freitag, den 15.12.2006, 21:53 -0500 schrieb Shawn O. Pearce: ...

Show 9 quoted lines
> @@ -292,7 +291,9 @@ void wt_status_print(struct wt_status *s)
>  	if (s->verbose && !s->is_initial)
>  		wt_status_print_verbose(s);
>  	if (!s->commitable)
> -		printf("%s\n", s->amend ? "# No changes" : "nothing to commit");
> +		printf("%s (%s)\n",
> +			s->amend ? "# No changes" : "nothing to commit",
> +			use_add_msg);
>  }

I don't like the new 'nothing to commit (use "git add ... message")' message. I use git status very often to see if there is something to commit, but now there is always this annoying "use git add ..." message. I just want to see on what the branch is and if there is something to commit.

If there is something to commit I get the list of untracked or modified files with the use_add_msg and if I try to commit an empty tree as initial commit I get the message from git-commit.sh.

bye
Junio C Hamano· Jan 5, 2007, 22:33 UTC · re: Michael Loeffler · lore
Michael Loeffler <zvpunry@zvpunry.de> writes:
Show 9 quoted lines
> Am Freitag, den 15.12.2006, 21:53 -0500 schrieb Shawn O. Pearce:
> ...
>> +		printf("%s (%s)\n",
>> +			s->amend ? "# No changes" : "nothing to commit",
>> +			use_add_msg);
>>  }
> I don't like the new 'nothing to commit (use "git add ... message")'
> message. I use git status very often to see if there is something to
> commit, but now there is always this annoying "use git add ..." message.

I tend to not like _ANY_ change at all, but I've learned to wait and see if I get used to it when I see something that annoys me initially, to see if the annoyance is because what it does is truly wrong or it is because what it does is merely different from what I am used to.

So I've been trying it out myself as one of the guinea pigs on this one as well.

So far, my judgement is that this is of the better kind; it is easy to get used to, and once you get used to it, it is easily ignorable.

Other people's tastes may differ, of course.
Junio C Hamano· Jan 6, 2007, 05:57 UTC · re: Junio C Hamano · lore
Junio C Hamano <junkio@cox.net> writes:
Show 24 quoted lines
> Michael Loeffler <zvpunry@zvpunry.de> writes:
>
>> Am Freitag, den 15.12.2006, 21:53 -0500 schrieb Shawn O. Pearce:
>> ...
>>> +		printf("%s (%s)\n",
>>> +			s->amend ? "# No changes" : "nothing to commit",
>>> +			use_add_msg);
>>>  }
>> I don't like the new 'nothing to commit (use "git add ... message")'
>> message. I use git status very often to see if there is something to
>> commit, but now there is always this annoying "use git add ..." message.
>
> I tend to not like _ANY_ change at all, but I've learned to wait
> and see if I get used to it when I see something that annoys me
> initially, to see if the annoyance is because what it does is
> truly wrong or it is because what it does is merely different
> from what I am used to.
>
> So I've been trying it out myself as one of the guinea pigs on
> this one as well.
>
> So far, my judgement is that this is of the better kind; it is
> easy to get used to, and once you get used to it, it is easily
> ignorable.
How about doing this?

-- >8 -- git-status: squelch "use 'git add file...'" message when unneeded

Add a field in wt_status to record if there are any uncached changes, and use it to decide when there is no point to add the "use 'git add'" message.

---
Show changes to 2 files +18 −9

wt-status.c, wt-status.h

diff --git a/wt-status.c b/wt-status.c
index db42738..1037c94 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -15,7 +15,7 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
 	"\033[31m", /* WT_STATUS_CHANGED: red */
 	"\033[31m", /* WT_STATUS_UNTRACKED: red */
 };
-static const char* use_add_msg = "use \"git add file1 file2\" to include for commit";
+static const char* use_add_msg = "use \"git add file...\" to include for commit";
 
 static int parse_status_slot(const char *var, int offset)
 {
@@ -162,13 +162,17 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
                         struct diff_options *options,
                         void *data)
 {
+	struct wt_status *s = (struct wt_status *)data;
 	int i;
-	if (q->nr)
-		wt_status_print_header("Changed but not added", use_add_msg);
+
+	s->modified = q->nr;
+	if (!q->nr)
+		return;
+
+	wt_status_print_header("Changed but not added", use_add_msg);
 	for (i = 0; i < q->nr; i++)
 		wt_status_print_filepair(WT_STATUS_CHANGED, q->queue[i]);
-	if (q->nr)
-		wt_status_print_trailer();
+	wt_status_print_trailer();
 }
 
 void wt_status_print_initial(struct wt_status *s)
@@ -291,10 +295,14 @@ void wt_status_print(struct wt_status *s)
 
 	if (s->verbose && !s->is_initial)
 		wt_status_print_verbose(s);
-	if (!s->commitable)
-		printf("%s (%s)\n",
-			s->amend ? "# No changes" : "nothing to commit",
-			use_add_msg);
+	if (!s->commitable) {
+		const char *msg =
+			s->amend ? "# No changes" : "nothing to commit";
+		if (s->modified)
+			printf("%s (%s)\n", msg, use_add_msg);
+		else
+			printf("%s\n", msg);
+	}
 }
 
 int git_status_config(const char *k, const char *v)
diff --git a/wt-status.h b/wt-status.h
index 0a5a5b7..72df1b3 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -13,6 +13,7 @@ struct wt_status {
 	char *branch;
 	const char *reference;
 	int commitable;
+	int modified;
 	int verbose;
 	int amend;
 	int untracked;
Juergen Ruehle· Jan 6, 2007, 13:33 UTC · re: Junio C Hamano · lore
Junio C Hamano writes:
 > Junio C Hamano <junkio@cox.net> writes:
 > 
 > > Michael Loeffler <zvpunry@zvpunry.de> writes:
 > >
 > >> Am Freitag, den 15.12.2006, 21:53 -0500 schrieb Shawn O. Pearce:
 > >> ...
 > >>> +		printf("%s (%s)\n",
 > >>> +			s->amend ? "# No changes" : "nothing to commit",
 > >>> +			use_add_msg);
 > >>>  }
 > >> I don't like the new 'nothing to commit (use "git add ... message")'
 > >> message. I use git status very often to see if there is something to
 > >> commit, but now there is always this annoying "use git add ..." message.
 > >
 > > I tend to not like _ANY_ change at all, but I've learned to wait
 > > and see if I get used to it when I see something that annoys me
 > > initially, to see if the annoyance is because what it does is
 > > truly wrong or it is because what it does is merely different
 > > from what I am used to.
 > >
 > > So I've been trying it out myself as one of the guinea pigs on
 > > this one as well.
 > >
 > > So far, my judgement is that this is of the better kind; it is
 > > easy to get used to, and once you get used to it, it is easily
 > > ignorable.
 > 
 > How about doing this?
 > 
 > -- >8 --
 > git-status: squelch "use 'git add file...'" message when unneeded
 > 
 > Add a field in wt_status to record if there are any uncached
 > changes, and use it to decide when there is no point to add the
 > "use 'git add'" message.

Commit 6e458bf63f48fb7d15cb70ad7c7b7b71915d94a2 in next is already doing exactly that. Or am I missing something?

Junio C Hamano· Jan 6, 2007, 18:17 UTC · re: Juergen Ruehle · lore
Juergen Ruehle <j.ruehle@bmiag.de> writes:
Show 11 quoted lines
>  > How about doing this?
>  > 
>  > -- >8 --
>  > git-status: squelch "use 'git add file...'" message when unneeded
>  > 
>  > Add a field in wt_status to record if there are any uncached
>  > changes, and use it to decide when there is no point to add the
>  > "use 'git add'" message.
>
> Commit 6e458bf63f48fb7d15cb70ad7c7b7b71915d94a2 in next is already
> doing exactly that. Or am I missing something?

If there is something you are missing, it is that I am overloaded these days ;-).

Thanks for the reminder.
Juergen Ruehle· Jan 6, 2007, 23:00 UTC · re: Junio C Hamano · lore
Junio C Hamano writes:
 > If there is something you are missing, it is that I am
 > overloaded these days ;-).

I'm sorry. As a rather unsuccessful former maintainer of http://www.openarchitectureware.org/ I can fully appreciate git's luck to have such a dedicated maintainer.

Junio C Hamano· Jan 8, 2007, 05:48 UTC · re: Juergen Ruehle · lore
Juergen Ruehle <j.ruehle@bmiag.de> writes:
Show 7 quoted lines
> Junio C Hamano writes:
>  > If there is something you are missing, it is that I am
>  > overloaded these days ;-).
>
> I'm sorry. As a rather unsuccessful former maintainer of
> http://www.openarchitectureware.org/ I can fully appreciate git's luck
> to have such a dedicated maintainer.

Actually there is one difference that I found practically important. It usually is a norm for me to have a handful untracked files that I do not even bother adding to .gitignore in the repository. My patch does not suggest "add" when there are untracked files but no locally modified files.

Juergen Ruehle· Jan 8, 2007, 10:42 UTC · re: Junio C Hamano · lore
Junio C Hamano writes:
 > Juergen Ruehle <j.ruehle@bmiag.de> writes:
 > 
 > > Junio C Hamano writes:
 > >  > If there is something you are missing, it is that I am
 > >  > overloaded these days ;-).
 > >
 > > I'm sorry. As a rather unsuccessful former maintainer of
 > > http://www.openarchitectureware.org/ I can fully appreciate git's luck
 > > to have such a dedicated maintainer.
 > 
 > Actually there is one difference that I found practically
 > important.  It usually is a norm for me to have a handful
 > untracked files that I do not even bother adding to .gitignore
 > in the repository.  My patch does not suggest "add" when there
 > are untracked files but no locally modified files.

Yes. I don't have a real preference. I have a slight suspicion that the hint is useful for newbies because having only untracked files is the initial situation, but the hint in my patch is actually wrong because git-commit won't help in this situation. Do you want to revert the patch and apply yours or should I send a correction?

Junio C Hamano· Jan 8, 2007, 20:13 UTC · re: Juergen Ruehle · lore
Juergen Ruehle <j.ruehle@bmiag.de> writes:
Show 22 quoted lines
> Junio C Hamano writes:
>  > Juergen Ruehle <j.ruehle@bmiag.de> writes:
>  > 
>  > > Junio C Hamano writes:
>  > >  > If there is something you are missing, it is that I am
>  > >  > overloaded these days ;-).
>  > >
>  > > I'm sorry. As a rather unsuccessful former maintainer of
>  > > http://www.openarchitectureware.org/ I can fully appreciate git's luck
>  > > to have such a dedicated maintainer.
>  > 
>  > Actually there is one difference that I found practically
>  > important.  It usually is a norm for me to have a handful
>  > untracked files that I do not even bother adding to .gitignore
>  > in the repository.  My patch does not suggest "add" when there
>  > are untracked files but no locally modified files.
>
> Yes. I don't have a real preference. I have a slight suspicion that
> the hint is useful for newbies because having only untracked files is
> the initial situation, but the hint in my patch is actually wrong
> because git-commit won't help in this situation. Do you want to revert
> the patch and apply yours or should I send a correction?

I think it is Ok to give hints for untracked files -- with experience eyes will learn to ignore them but by then they do not need hints. Please send in a correction as appropriate.

Juergen Ruehle· Jan 10, 2007, 07:08 UTC · re: Junio C Hamano · lore

[PATCH] Provide better feedback for the untracked only case in status output

From: =?utf-8?q?J=C3=BCrgen_R=C3=BChle?= <j-r@online.de>

Since 98bf8a47c296f51ea9722fef4bb81dbfb70cd4bb status would claim that git-commit could be useful even if there are no changes except untracked files.

Since wt-status is already computing all the information go the whole way and separately track the (non-)emptiness of all three sections, unify the code, and provide separate messages for each case. This adds a new message for the untracked only case and adds an explanation for a completely empty working directory during initial commit.

This change is effectively reverting 98bf8a47c296f51ea9722fef4bb81dbfb70cd4bb and replacing it by a cleaner version.

Signed-off-by: Jürgen Rühle <j-r@online.de>
---
  Junio C Hamano writes:
   > I think it is Ok to give hints for untracked files -- with
   > experience eyes will learn to ignore them but by then they do
   > not need hints.  Please send in a correction as appropriate.
  This should provide useful feedback for the nothing to commit case in any
  situation. It is how I should have done it initially. Sorry for wasting your
  time.
  Still missing:
   - Further changes to the header messages (as discussed on the list)
   - Patches to every other file that contains these messages verbatim
     (AFAICS this affects only the git-reset man page, tutorial-2 and the VIM
      syntax highlighting)
 wt-status.c |   21 ++++++++++++---------
 wt-status.h |    6 ++++--
 2 files changed, 16 insertions(+), 11 deletions(-)
Show changes to 2 files +16 −11

wt-status.c, wt-status.h

diff --git a/wt-status.c b/wt-status.c
index c48127d..5190bde 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -47,10 +47,11 @@ void wt_status_prepare(struct wt_status *s)
 	s->reference = "HEAD";
 	s->amend = 0;
 	s->verbose = 0;
-	s->commitable = 0;
 	s->untracked = 0;
 
-	s->workdir_clean = 1;
+	s->commitable = 0;
+	s->workdir_dirty = 0;
+	s->workdir_untracked = 0;
 }
 
 static void wt_status_print_cached_header(const char *reference)
@@ -176,7 +177,7 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
 	struct wt_status *s = data;
 	int i;
 	if (q->nr) {
-		s->workdir_clean = 0;
+		s->workdir_dirty = 1;
 		wt_status_print_header("Changed but not added", use_add_msg);
 	}
 	for (i = 0; i < q->nr; i++)
@@ -263,7 +264,7 @@ static void wt_status_print_untracked(struct wt_status *s)
 				continue;
 		}
 		if (!shown_header) {
-			s->workdir_clean = 0;
+			s->workdir_untracked = 1;
 			wt_status_print_header("Untracked files", use_add_msg);
 			shown_header = 1;
 		}
@@ -311,12 +312,14 @@ void wt_status_print(struct wt_status *s)
 	if (!s->commitable) {
 		if (s->amend)
 			printf("# No changes\n");
-		else if (s->workdir_clean)
-			printf(s->is_initial
-			       ? "nothing to commit\n"
-			       : "nothing to commit (working directory matches HEAD)\n");
-		else
+		else if (s->workdir_dirty)
 			printf("no changes added to commit (use \"git add\" and/or \"git commit [-a|-i|-o]\")\n");
+		else if (s->workdir_untracked)
+			printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
+		else if (s->is_initial)
+			printf("nothing to commit (working directory is empty)\n");
+		else
+			printf("nothing to commit (working directory matches HEAD)\n");
 	}
 }
 
diff --git a/wt-status.h b/wt-status.h
index 892a86c..cfea4ae 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -12,11 +12,13 @@ struct wt_status {
 	int is_initial;
 	char *branch;
 	const char *reference;
-	int commitable;
 	int verbose;
 	int amend;
 	int untracked;
-	int workdir_clean;
+	/* These are computed during processing of the individual sections */
+	int commitable;
+	int workdir_dirty;
+	int workdir_untracked;
 };
 
 int git_status_config(const char *var, const char *value);
-- 
1.5.0.rc0.g525e
Juergen Ruehle· Jan 10, 2007, 07:29 UTC · re: Juergen Ruehle · lore

Re: [PATCH] Provide better feedback for the untracked only case in status output

Juergen Ruehle writes:
 > Juergen Ruehle writes:
 >  > [Corrupted patch deleted]

Actually the patch is ok as sent (somehow my MUA was adding CRs when locally saving the patch). Sorry for the noise.

Junio C Hamano· Jan 10, 2007, 07:39 UTC · re: Juergen Ruehle · lore

Re: [PATCH] Provide better feedback for the untracked only case in status output

Juergen Ruehle <j.ruehle@bmiag.de> writes:
> Juergen Ruehle writes:
>  > [Corrupted patch deleted]
>
> Will try again when I know what happened.

While you are at it, let me point out one thing that has been annoying me for a while.

This is an example e-mail I have been getting from you (the below is before decoding MIME):

  From: Juergen Ruehle <j.ruehle@bmiag.de>
  Subject: [PATCH] Provide better feedback for the ...
  Date: Wed, 10 Jan 2007 08:08:12 +0100
  Message-ID: <1168412892113-git-send-email-j.ruehle@bmiag.de>
  Content-Type: text/plain; charset=UTF-8
  Content-Transfer-Encoding: quoted-printable
  Cc: git@vger.kernel.org,
          =?utf-8?q?J=C3=BCrgen_R=C3=BChle?= <j-r@online.de>
  X-Mailer: git-send-email 1.5.0.rc0.g525e
  From: =3D?utf-8?q?J=3DC3=3DBCrgen_R=3DC3=3DBChle?=3D <j-r@online.de>
  Since 98bf8a47c296f51ea9722fef4bb81dbfb70cd4bb status would claim that
  git-commit could be useful even if there are no changes except untracked =
  files.
  Since wt-status is already computing all the information go the whole way=
   and
  separately track the (non-)emptiness of all three sections, unify the cod=
  e, and
  provide separate messages for each case. This adds a new message for the
  untracked only case and adds an explanation for a completely empty workin=
  g
  directory during initial commit.
  This change is effectively reverting 98bf8a47c296f51ea9722fef4bb81dbfb70c=
  d4bb
  and replacing it by a cleaner version.
  Signed-off-by: J=C3=BCrgen R=C3=BChle <j-r@online.de>
Notice:
 * The message claims to be from git-send-email;
 * Content-Type and CTE are UTF-8 and QP (which is fine);
 * You have in-body From: line; this is not wrong per-se and I
   understand why you would want one (your e-mail From: line
   uses ASCII approximations "ue" and "ue" and you would want
   the resulting commit to spell your name correctly).
 * However, this in-body From: line is _doubly_ QP encoded (what
   you see above is your name, first RFC 2047 encoded and then
   QP encoded).  It shouldn't be.
So, my questions are:
 (1) is this what git-send-email generates and sends out by
     default?  If so that means it is a bug in that program that
     needs to be fixed.
 (2) if not, are you inserting the in-body From: by hand,
     perhaps cut & paste from format-patch output, before
     feeding git-send-email (which runs QP on it)?

If the latter, please do not paste the RFC 2047 quoted form. You can spell your name in raw UTF-8 on the in-body From: line just like you did on your Signed-off-by: line.

Juergen Ruehle· Jan 10, 2007, 18:33 UTC · re: Junio C Hamano · lore

Re: [PATCH] Provide better feedback for the untracked only case in status output

Junio C Hamano writes:
 > Juergen Ruehle <j.ruehle@bmiag.de> writes:
 > 
 > > Juergen Ruehle writes:
 > >  > [Corrupted patch deleted]
 > >
 > > Will try again when I know what happened.
 > 
 > While you are at it, let me point out one thing that has been
 > annoying me for a while.
 > 
 >  * The message claims to be from git-send-email;
 > 
 >  * Content-Type and CTE are UTF-8 and QP (which is fine);
 > 
 >  * You have in-body From: line; this is not wrong per-se and I
 >    understand why you would want one (your e-mail From: line
 >    uses ASCII approximations "ue" and "ue" and you would want
 >    the resulting commit to spell your name correctly).
 >
 >  * However, this in-body From: line is _doubly_ QP encoded (what
 >    you see above is your name, first RFC 2047 encoded and then
 >    QP encoded).  It shouldn't be.
 > 
 > So, my questions are:
 > 
 >  (1) is this what git-send-email generates and sends out by
 >      default?  If so that means it is a bug in that program that
 >      needs to be fixed.
 > 
 >  (2) if not, are you inserting the in-body From: by hand,
 >      perhaps cut & paste from format-patch output, before
 >      feeding git-send-email (which runs QP on it)?
 > 
 > If the latter, please do not paste the RFC 2047 quoted form.
 > You can spell your name in raw UTF-8 on the in-body From: line
 > just like you did on your Signed-off-by: line.

Yes, this is using git-send-email which sends the mail as 8bit encoded and provides the QP encoded From line. Unfortunately there seems to be a gateway in between that doesn't handle 8bit and QPs the mail again. Perhaps I need some other switches for format-patch and send-email to produce a better result? I'll take another look at the documentation before annoying you again.

Juergen Ruehle· Jan 10, 2007, 20:07 UTC · re: Juergen Ruehle · lore

[PATCH] Quick hack to avoid double qp encoding

From: Jürgen_Rühle <j-r@online.de>
Signed-off-by: Jürgen Rühle <j-r@online.de>
---
 This is just a hack since I know next to nothing about perl.
 git-send-email.perl |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to git-send-email.perl +1 −0
diff --git a/git-send-email.perl b/git-send-email.perl
index ba39d39..a4a22d3 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -555,6 +555,7 @@ foreach my $t (@files) {
 	}
 	close F;
 	if (defined $author_not_sender) {
+		$author_not_sender =~ s/=\?utf-8\?q\?([^?]*)\?=/my $bla = $1; $bla =~ s|=([0-9a-fA-F]{2})|sprintf '%c', hex($1)|eg; $bla/eg;
 		$message = "From: $author_not_sender\n\n$message";
 	}
 
-- 
1.5.0.rc0.g525e
Juergen Ruehle· Jan 10, 2007, 20:37 UTC · re: Juergen Ruehle · lore

Re: [PATCH] Quick hack to avoid double qp encoding

Juergen Ruehle writes:
 > From: Jürgen_Rühle <j-r@online.de>
                ^

Ok, i should have also reverted the ' ' to '_' conversion, but it seems that send-email is to blame, because it simply copies the (possibly) QP encoded author address into the body of a (possibly) not QP encoded message.

 > Signed-off-by: Jürgen Rühle <j-r@online.de>
 > ---
 >  This is just a hack since I know next to nothing about perl.
 > 
 >  git-send-email.perl |    1 +
 >  1 files changed, 1 insertions(+), 0 deletions(-)
 > 
 > diff --git a/git-send-email.perl b/git-send-email.perl
 > index ba39d39..a4a22d3 100755
 > --- a/git-send-email.perl
 > +++ b/git-send-email.perl
 > @@ -555,6 +555,7 @@ foreach my $t (@files) {
 >  	}
 >  	close F;
 >  	if (defined $author_not_sender) {
 > +		$author_not_sender =~ s/=\?utf-8\?q\?([^?]*)\?=/my $bla = $1; $bla =~ s|=([0-9a-fA-F]{2})|sprintf '%c', hex($1)|eg; $bla/eg;
+		$author_not_sender =~ s/=\?utf-8\?q\?([^?]*)\?=/my $bla = $1; $bla =~ s|_| |g; $bla =~ s|=([0-9a-fA-F]{2})|sprintf '%c', hex($1)|eg; $bla/eg;
 >  		$message = "From: $author_not_sender\n\n$message";
 >  	}
 >  
 > -- 
 > 1.5.0.rc0.g525e
Junio C Hamano· Jan 10, 2007, 21:29 UTC · re: Juergen Ruehle · lore

Re: [PATCH] Quick hack to avoid double qp encoding

Juergen Ruehle <j.ruehle@bmiag.de> writes:
Show 6 quoted lines
> Juergen Ruehle writes:
>
> Ok, i should have also reverted the ' ' to '_' conversion, but it
> seems that send-email is to blame, because it simply copies the
> (possibly) QP encoded author address into the body of a (possibly) not
> QP encoded message.

Thanks. I think other people would want to hack on this, so I would make a separete sub to make it easier, like this:

Show changes to git-send-email.perl +10 −0
diff --git a/git-send-email.perl b/git-send-email.perl
index ba39d39..8dc2ee0 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -402,6 +402,15 @@ sub make_message_id
 $cc = "";
 $time = time - scalar $#files;
 
+sub unquote_rfc2047 {
+	local ($_) = @_;
+	if (s/=\?utf-8\?q\?(.*)\?=/$1/g) {
+		s/_/ /g;
+		s/=([0-9A-F]{2})/chr(hex($1))/eg;
+	}
+	return "$_ - unquoted";
+}
+
 sub send_message
 {
 	my @recipients = unique_email_list(@to);
@@ -555,6 +564,7 @@ foreach my $t (@files) {
 	}
 	close F;
 	if (defined $author_not_sender) {
+		$author_not_sender = unquote_rfc2047($author_not_sender);
 		$message = "From: $author_not_sender\n\n$message";
 	}
 
Michael Loeffler· Jan 10, 2007, 18:16 UTC · re: Juergen Ruehle · lore

Re: [PATCH] Provide better feedback for the untracked only case in status output

hi,

Am Mittwoch, den 10.01.2007, 08:08 +0100 schrieb Juergen Ruehle: ...

> @@ -311,12 +312,14 @@ void wt_status_print(struct wt_status *s)
...
> +		else if (s->is_initial)
> +			printf("nothing to commit (working directory is empty)\n");
Shouldn't the user know that there is nothing in his working directory?
> +		else
> +			printf("nothing to commit (working directory matches HEAD)\n");
How about s/matches HEAD/clean/

There is another thing: # Changed but not added: # (use "git add <file>..." to incrementally add content to commit) # # deleted: blah

How about adding some more hints (e.g.: git rm --cached <file>) depending on the diff_queue in wt_status_print_changed_cb()?

bye michael
Juergen Ruehle· Jan 10, 2007, 20:14 UTC · re: Michael Loeffler · lore

Re: [PATCH] Provide better feedback for the untracked only case in status output

Michael Loeffler writes:
 > hi,
 > 
 > Am Mittwoch, den 10.01.2007, 08:08 +0100 schrieb Juergen Ruehle:
 > ...
 > > @@ -311,12 +312,14 @@ void wt_status_print(struct wt_status *s)
 > ...
 > > +		else if (s->is_initial)
 > > +			printf("nothing to commit (working directory is empty)\n");
 > Shouldn't the user know that there is nothing in his working directory?
:-)

Well this is the state directly after git-init, e.g. the very first contact with git. Perhaps we should write:

nothing to commit (create files in the working directory and use git add)
 > > +		else
 > > +			printf("nothing to commit (working directory matches HEAD)\n");
 > How about s/matches HEAD/clean/
I like that.
 > There is another thing:
 > # Changed but not added:
 > #   (use "git add <file>..." to incrementally add content to commit)
 > #
 > #       deleted:    blah
 > 
 > How about adding some more hints (e.g.: git rm --cached <file>)
 > depending on the diff_queue in wt_status_print_changed_cb()?
Yes, there's always one more case to consider:-)
Juergen Ruehle· Jan 10, 2007, 22:25 UTC · re: Michael Loeffler · lore

[PATCH] Provide better feedback for the untracked only case in status output

From: Jürgen Rühle <j-r@online.de>

Since 98bf8a47c296f51ea9722fef4bb81dbfb70cd4bb status would claim that git-commit could be useful even if there are no changes except untracked files.

Since wt-status is already computing all the information needed go the whole way and actually track the (non-)emptiness of all three sections separately, unify the code, and provide useful messages for each individual case.

Thanks to Junio and Michael Loeffler for suggestions.
Signed-off-by: Jürgen Rühle <j-r@online.de>
---
  This is a resend of the nothing-to-commit improvement patch (hopefully)
  without corruption. This also includes some changes due to feedback from
  Michael Loeffler.
  Still missing:
   - Further changes to the other messages (as discussed on the list)
   - Patches to other files that contain these messages verbatim
     (AFAICS this affects only the git-reset man page, tutorial-2 and the VIM
      syntax highlighting)
 wt-status.c |   21 ++++++++++++---------
 wt-status.h |    6 ++++--
 2 files changed, 16 insertions(+), 11 deletions(-)
Show changes to 2 files +16 −11

wt-status.c, wt-status.h

diff --git a/wt-status.c b/wt-status.c
index c48127d..1dc2fdc 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -47,10 +47,11 @@ void wt_status_prepare(struct wt_status *s)
 	s->reference = "HEAD";
 	s->amend = 0;
 	s->verbose = 0;
-	s->commitable = 0;
 	s->untracked = 0;
 
-	s->workdir_clean = 1;
+	s->commitable = 0;
+	s->workdir_dirty = 0;
+	s->workdir_untracked = 0;
 }
 
 static void wt_status_print_cached_header(const char *reference)
@@ -176,7 +177,7 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
 	struct wt_status *s = data;
 	int i;
 	if (q->nr) {
-		s->workdir_clean = 0;
+		s->workdir_dirty = 1;
 		wt_status_print_header("Changed but not added", use_add_msg);
 	}
 	for (i = 0; i < q->nr; i++)
@@ -263,7 +264,7 @@ static void wt_status_print_untracked(struct wt_status *s)
 				continue;
 		}
 		if (!shown_header) {
-			s->workdir_clean = 0;
+			s->workdir_untracked = 1;
 			wt_status_print_header("Untracked files", use_add_msg);
 			shown_header = 1;
 		}
@@ -311,12 +312,14 @@ void wt_status_print(struct wt_status *s)
 	if (!s->commitable) {
 		if (s->amend)
 			printf("# No changes\n");
-		else if (s->workdir_clean)
-			printf(s->is_initial
-			       ? "nothing to commit\n"
-			       : "nothing to commit (working directory matches HEAD)\n");
-		else
+		else if (s->workdir_dirty)
 			printf("no changes added to commit (use \"git add\" and/or \"git commit [-a|-i|-o]\")\n");
+		else if (s->workdir_untracked)
+			printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
+		else if (s->is_initial)
+			printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
+		else
+			printf("nothing to commit (working directory clean)\n");
 	}
 }
 
diff --git a/wt-status.h b/wt-status.h
index 892a86c..cfea4ae 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -12,11 +12,13 @@ struct wt_status {
 	int is_initial;
 	char *branch;
 	const char *reference;
-	int commitable;
 	int verbose;
 	int amend;
 	int untracked;
-	int workdir_clean;
+	/* These are computed during processing of the individual sections */
+	int commitable;
+	int workdir_dirty;
+	int workdir_untracked;
 };
 
 int git_status_config(const char *var, const char *value);
-- 
1.5.0.rc0.g525e
Jeff King· Jan 10, 2007, 22:29 UTC · re: Juergen Ruehle · lore

Re: [PATCH] Provide better feedback for the untracked only case in status output

On Wed, Jan 10, 2007 at 11:25:03PM +0100, Juergen Ruehle wrote:
>    - Patches to other files that contain these messages verbatim
>      (AFAICS this affects only the git-reset man page, tutorial-2 and the VIM
>       syntax highlighting)

I have been tracking these changes for the vim highlighting, but have been waiting for things to settle before sending a patch (which should hopefully go into v1.5.0, but I will wait until this is finalized).

-Peff
Juergen Ruehle· Jan 11, 2007, 07:17 UTC · re: Jeff King · lore

Re: [PATCH] Provide better feedback for the untracked only case in status output

Jeff King writes:
 > On Wed, Jan 10, 2007 at 11:25:03PM +0100, Juergen Ruehle wrote:
 > 
 > >    - Patches to other files that contain these messages verbatim
 > >      (AFAICS this affects only the git-reset man page, tutorial-2 and the VIM
 > >       syntax highlighting)
 > 
 > I have been tracking these changes for the vim highlighting, but have
 > been waiting for things to settle before sending a patch (which should
 > hopefully go into v1.5.0, but I will wait until this is finalized).

Thanks for tracking this. It would be nice if we could make the syntax highlighting less dependent on the exact wording.

Juergen Ruehle· Jan 6, 2007, 14:02 UTC · re: Michael Loeffler · lore
Michael Loeffler writes:
 > Hi,
 > 
 > Am Freitag, den 15.12.2006, 21:53 -0500 schrieb Shawn O. Pearce:
 > ...
 > > @@ -292,7 +291,9 @@ void wt_status_print(struct wt_status *s)
 > >  	if (s->verbose && !s->is_initial)
 > >  		wt_status_print_verbose(s);
 > >  	if (!s->commitable)
 > > -		printf("%s\n", s->amend ? "# No changes" : "nothing to commit");
 > > +		printf("%s (%s)\n",
 > > +			s->amend ? "# No changes" : "nothing to commit",
 > > +			use_add_msg);
 > >  }
 > I don't like the new 'nothing to commit (use "git add ... message")'
 > message. I use git status very often to see if there is something to
 > commit, but now there is always this annoying "use git add ..." message.
 > I just want to see on what the branch is and if there is something to
 > commit.
 > 
 > If there is something to commit I get the list of untracked or modified
 > files with the use_add_msg and if I try to commit an empty tree as
 > initial commit I get the message from git-commit.sh.

I'd appreciate feedback on my series from the 2nd of January, especially part 3/4 (Subject: [PATCH 3/4] Improve "nothing to commit" part of status output). This is already part of next.

It removes the message if there really is nothing to commit and replaces it by a generic pointer to git add and git commit if there are pending changes in the working directory.

Michael Loeffler· Jan 8, 2007, 19:18 UTC · re: Juergen Ruehle · lore
hi,

Am Samstag, den 06.01.2007, 15:02 +0100 schrieb Juergen Ruehle: ...

> I'd appreciate feedback on my series from the 2nd of January,
> especially part 3/4 (Subject: [PATCH 3/4] Improve "nothing to commit"
> part of status output). This is already part of next.

A very positive feedback from me, I like this and it is much better then just removing this "use git add"-message. ;)

bye michael
Juergen Ruehle· Jan 9, 2007, 05:42 UTC · re: Michael Loeffler · lore
Michael Loeffler writes:
 > hi,
 > 
 > Am Samstag, den 06.01.2007, 15:02 +0100 schrieb Juergen Ruehle:
 > ...
 > > I'd appreciate feedback on my series from the 2nd of January,
 > > especially part 3/4 (Subject: [PATCH 3/4] Improve "nothing to commit"
 > > part of status output). This is already part of next.
 > A very positive feedback from me, I like this and it is much better then
 > just removing this "use git add"-message. ;)

How about Junio's case where there are only untracked files in the working directory? I tend to send a patch that either just prints "nothing to commit" (simpler) or provides a different message that just advertises git-add.

← back to recent threads