Skip to contentSkip to conversation

"not uptodate" changed to "has local changes"

PATCH In review Tim Harper 13 participants 24 messages Jun 15, 2016 1 message not in the archive Documentation

lore
Share & tools
lore

Tim Harper

author
#0 lore raw

PATCH 1/1 "not uptodate" changed to "has local changes"

When doing a merge, the message says "file.txt: needs update", or "file.txt: not uptodate, cannot merge". While internally 'uptodate' makes sense, from the outside it's a mystery.

This patch will make git a little more human friendly, reporting "file.txt: has local changes".

---
 read-cache.c   |    2 +-
 unpack-trees.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
read-cache.c +1 -1
index a92b25b..e890b27 100644
@@ -999,7 +999,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
 			}
 			if (quiet)
 				continue;
-			printf("%s: needs update\n", ce->name);
+			printf("%s: has local changes\n", ce->name);
 			has_errors = 1;
 			continue;
 		}
unpack-trees.c +1 -1
index a59f475..1d67e08 100644
@@ -427,7 +427,7 @@ static int verify_uptodate(struct cache_entry *ce,
 	if (errno == ENOENT)
 		return 0;
 	return o->gently ? -1 :
-		error("Entry '%s' not uptodate. Cannot merge.", ce->name);
+		error("Entry '%s' has local changes. Cannot merge.", ce->name);
 }
 
 static void invalidate_ce_path(struct cache_entry *ce, struct unpack_trees_options *o)
Signature · 1 line
1.5.5.1
#1 lore raw

2008/5/3 Tim Harper <[email protected]>:

Quoted 3 lines

When doing a merge, the message says "file.txt: needs update", or "file.txt: not uptodate, cannot merge". While internally 'uptodate' makes sense, from the outside it's a mystery.

This patch will make git a little more human friendly, reporting "file.txt: has local changes".

Documentation/git-checkout.txt should also change in this case, otherwise users will see different output to that described and possibly get confused if following along with the examples.

Mike

#2 lore raw
Quoted 6 lines
Quoted 1 line

This patch will make git a little more human friendly, reporting "file.txt: has local changes".

Documentation/git-checkout.txt should also change in this case, otherwise users will see different output to that described and possibly get confused if following along with the examples.

I like the idea too.

---
[PATCH] "not uptodate" changed to "has local changes"

Use more straightforward message for regular user.

Documentation/git-checkout.txt +1 -1
index a644173..624dea6 100644
@@ -168,7 +168,7 @@ the above checkout would fail like this:
 +
 ------------
 $ git checkout mytopic
-fatal: Entry 'frotz' not uptodate. Cannot merge.
+fatal: Entry 'frotz' has local changes. Cannot merge.
 ------------
 +
 You can give the `-m` flag to the command, which would try a
#3 lore raw

Hi,

Quoted 8 lines · André Goddard Rosa
Quoted 6 lines
Quoted 1 line

This patch will make git a little more human friendly, reporting "file.txt: has local changes".

Documentation/git-checkout.txt should also change in this case, otherwise users will see different output to that described and possibly get confused if following along with the examples.

I like the idea too.

No comment on the concern that it might break people's scripts? None?

Ciao,
Dscho

#4 lore raw
Quoted 5 lines · Johannes Schindelin
Quoted 3 lines · André Goddard Rosa
Quoted 3 lines
Quoted 2 lines

This patch will make git a little more human friendly, reporting "file.txt: has local changes".

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Documentation/git-checkout.txt should also change in this case, otherwise users will see different output to that described and possibly get confused if following along with the examples.

I like the idea too.

No comment on the concern that it might break people's scripts? None?

How about an ugly hack? Look to see if stdout is a tty, if so spit out the more human-readable version, otherwise spit out the old version >:-)

-Kevin

Signature · 4 lines
Kevin Ballard
http://kevin.sb.org
[email protected]
http://www.tildesoft.com
#5 lore raw
Quoted 12 lines · Kevin Ballard
Quoted 10 lines · Johannes Schindelin
Quoted 8 lines · André Goddard Rosa
Quoted 7 lines
Quoted 2 lines

This patch will make git a little more human friendly, reporting "file.txt: has local changes".

Documentation/git-checkout.txt should also change in this case, otherwise users will see different output to that described and possibly get confused if following along with the examples.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

I like the idea too.

No comment on the concern that it might break people's scripts? None?

How about an ugly hack? Look to see if stdout is a tty, if so spit out the more human-readable version, otherwise spit out the old version >:-)

Is this user interface set on stone? I think we should reserve the right to improve always.

I would deprecate the current message, but I think that most users cannot find so much of a sense in the former message, although the script developer can easily change his scripts to search for ´cannot merge´ instead.

Do you have a better idea?

---
[PATCH] "not uptodate" changed to "has local changes"

Use more straightforward message for regular user.

Documentation/git-checkout.txt +1 -1
index a644173..624dea6 100644
@@ -168,7 +168,7 @@ the above checkout would fail like this:
 +
 ------------
 $ git checkout mytopic
-fatal: Entry 'frotz' not uptodate. Cannot merge.
+fatal: Entry 'frotz' not uptodate, it has local changes. Cannot merge.
 ------------
 +
 You can give the `-m` flag to the command, which would try a
#6 lore raw

Hi,

Quoted 15 lines · André Goddard Rosa
Quoted 14 lines · Kevin Ballard
Quoted 12 lines · Johannes Schindelin
Quoted 9 lines · André Goddard Rosa
Quoted 7 lines
Quoted 2 lines

This patch will make git a little more human friendly, reporting "file.txt: has local changes".

Documentation/git-checkout.txt should also change in this case, otherwise users will see different output to that described and possibly get confused if following along with the examples.

I like the idea too.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

No comment on the concern that it might break people's scripts? None?

How about an ugly hack? Look to see if stdout is a tty, if so spit out the more human-readable version, otherwise spit out the old version >:-)

Is this user interface set on stone? I think we should reserve the right to improve always.

Umm.

As has been mentioned, this is not a "user interface". The message you are seeing comes from a _plumbing_ program, i.e. something _not_ meant for human consumption.

I still think that it might be better to add a command line option with a custom message, because that would _not_ break backwards-compatibility.

Thankyouverymuch,
Dscho

#7 lore raw
Quoted 8 lines · Johannes Schindelin

Hi,

Quoted 3 lines · André Goddard Rosa

Is this user interface set on stone? I think we should reserve the right
to improve always.

Quoted 7 lines

Umm.

As has been mentioned, this is not a "user interface". The message you
are seeing comes from a _plumbing_ program, i.e. something _not_ meant for
human consumption.

That would indicate a problem, if stuff not intended for human consumption is being dished up for exactly that: human consumption.

Quoted 4 lines

I still think that it might be better to add a command line option with a
custom message, because that would _not_ break backwards- compatibility.

Sounds like clutter to me. I'd instead favor just holding back this patch until 1.6, when (minor) "compatibility breaking" changes would be acceptable.

Wincent

#8 lore raw
Quoted 2 lines · Wincent Colaiuta

That would indicate a problem, if stuff not intended for human consumption is being dished up for exactly that: human consumption.

There have been other instances of this one, and the output of git-update-index has been replaced by a call to "git status" in the porcelain.

Signature · 1 line
Matthieu
#9 lore raw
In reply to Johannes Schindelin
Quoted 11 lines · Johannes Schindelin
Quoted 2 lines

Is this user interface set on stone? I think we should reserve the right to improve always.

Umm.

As has been mentioned, this is not a "user interface". The message you are seeing comes from a _plumbing_ program, i.e. something _not_ meant for human consumption.

I still think that it might be better to add a command line option with a custom message, because that would _not_ break backwards-compatibility.

With this dedication to backwards-compatibility, we'll be at Windows Vista quality in no time.

Signature · 1 line
-Steven Walter <[email protected]>
#10 lore raw
Quoted 2 lines · Steven Walter

With this dedication to backwards-compatibility, we'll be at Windows Vista quality in no time.

I very much agree here, given the nature of scripts (that is, being very easy to update), I think we should try not to be too strict in backwards-compatibility or we'll lose the flexibility that is very much needed when developing a Good Product (tm) As long as such compatibility breaking changes are marked (in BIG LETTERS) in the changelog/release notes I think that would be a 'sacrifice' we should consider making.

Signature · 3 lines
Cheers,

Sverre Rabbelier
#11 lore raw

Re* [PATCH] "not uptodate" changed to "has local changes"

Quoted 11 lines · Sverre Rabbelier
Quoted 2 lines · Steven Walter

With this dedication to backwards-compatibility, we'll be at Windows Vista quality in no time.

I very much agree here, given the nature of scripts (that is, being very easy to update), I think we should try not to be too strict in backwards-compatibility or we'll lose the flexibility that is very much needed when developing a Good Product (tm) As long as such compatibility breaking changes are marked (in BIG LETTERS) in the changelog/release notes I think that would be a 'sacrifice' we should consider making.

Don't feed the troll by responding to a cheap shot.

The plumbing output is sacred as it is an API. We _could_ change it if it is broken in such a way that it cannot convey necessary information fully, but we just do not _reword_ for the sake of rewording. If somebody does not like it, s/he is complaining too late. S/he should have been here in early May 2005 and make the language used by the API closer to what humans read. S/he wasn't here. Too bad, and it is too late.

And people who complain should look at a bigger picture. Look at what was suggested by one of them and think for five seconds:

     $ git checkout mytopic
    -fatal: Entry 'frotz' not uptodate. Cannot merge.
    +fatal: Entry 'frotz' has local changes. Cannot merge.

If you do not see something wrong with this output, your brain has already been rotten with use of git for too long a time. Nobody asked us to "merge" but why are we talking about "Cannot merge"?

Try a different approach along this patch instead.

    $ git-checkout pu
    error: You have local changes to 'Makefile'; cannot switch branches.

There are other places that ask unpack_trees() to n-way merge, detect issues _and_ let it issue error message on its own, which people who complained in this thread can identify and improve, but I did this as a demonstration and replaced only one message.

Yes I know about C99 structure initializers. I'd love to use them but we try to be nice to compilers without it.

 builtin-checkout.c |    2 ++
 unpack-trees.c     |   47 +++++++++++++++++++++++++++++++++--------------
 unpack-trees.h     |    9 +++++++++
 3 files changed, 44 insertions(+), 14 deletions(-)
builtin-checkout.c +2 -0
index 10ec137..83da7ca 100644
@@ -236,6 +236,8 @@ static int merge_working_tree(struct checkout_opts *opts,
 		topts.src_index = &the_index;
 		topts.dst_index = &the_index;
 
+		topts.msgs.not_uptodate_file = "You have local changes to '%s'; cannot switch branches.";
+
 		refresh_cache(REFRESH_QUIET);
 
 		if (unmerged_cache()) {
unpack-trees.c +33 -14

104 lines not on this page · raw message

unpack-trees.h +9 -0
index d436d6c..94e5672 100644
@@ -8,6 +8,14 @@ struct unpack_trees_options;
 typedef int (*merge_fn_t)(struct cache_entry **src,
 		struct unpack_trees_options *options);
 
+struct unpack_trees_error_msgs {
+	const char *would_overwrite;
+	const char *not_uptodate_file;
+	const char *not_uptodate_dir;
+	const char *would_lose_untracked;
+	const char *bind_overlap;
+};
+
 struct unpack_trees_options {
 	unsigned int reset:1,
 		     merge:1,
@@ -23,6 +31,7 @@ struct unpack_trees_options {
 	int pos;
 	struct dir_struct *dir;
 	merge_fn_t fn;
+	struct unpack_trees_error_msgs msgs;
 
 	int head_idx;
 	int merge_size;
#12 lore raw

Re: Re* [PATCH] "not uptodate" changed to "has local changes"

unpack-trees.c line 16

Quoted 2 lines · Junio C Hamano
unpack-trees.c +2 -0
+	/* not_uptodate_file */
+	"Entry '%s' not uptodate. Cannot merge.",

Minor nit, "uptodate" is not a word. Should be either "up-to-date" or "up to date"; most dictionaries list both.

Cheers,
Wincent

#13 lore raw

Re: Re* [PATCH] "not uptodate" changed to "has local changes"

Quoted 7 lines · Wincent Colaiuta

unpack-trees.c line 16

Quoted 2 lines · Junio C Hamano
unpack-trees.c +2 -0
+	/* not_uptodate_file */
+	"Entry '%s' not uptodate. Cannot merge.",

Minor nit, "uptodate" is not a word. Should be either "up-to-date" or "up to date"; most dictionaries list both.

Why does *everybody* keep missing the whole point of this patch?

Grumble.

#14 lore raw

Re: Re* [PATCH] "not uptodate" changed to "has local changes"

Quoted 11 lines · Junio C Hamano
Quoted 7 lines · Wincent Colaiuta

unpack-trees.c line 16

Quoted 2 lines · Junio C Hamano
unpack-trees.c +2 -0
+	/* not_uptodate_file */
+	"Entry '%s' not uptodate. Cannot merge.",

Minor nit, "uptodate" is not a word. Should be either "up-to-date" or "up to date"; most dictionaries list both.

Why does *everybody* keep missing the whole point of this patch?

That section needs a comment stating that it's the scripting API, not just an arbitrary set of messages. For that matter, maybe those shouldn't be the default set, but an alternate set used (as a group) by plumbing programs; I don't think it's too likely that there will be a whole lot of new plumbing programs, and new porcelain programs that don't specify anything probably ought to get something more generic.

-Daniel
*This .sig left intentionally blank*

#15 lore raw

Re: Re* [PATCH] "not uptodate" changed to "has local changes"

Quoted 6 lines · Daniel Barkalow
Quoted 1 line · Junio C Hamano

Why does *everybody* keep missing the whole point of this patch?

That section needs a comment stating that it's the scripting API, not just an arbitrary set of messages.

Yeah, that is a very good explanation. Thanks for a constructive suggestion for improvements.

Here is an incremental on top of the one I sent out, in case people want to improve on it.

 unpack-trees.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
unpack-trees.c +10 -2
index da3bdc8..0de5a31 100644
@@ -8,7 +8,15 @@
 #include "progress.h"
 #include "refs.h"
 
-static struct unpack_trees_error_msgs unpack_default_errors = {
+/*
+ * Error messages expected by scripts out of plumbing commands such as
+ * read-tree.  Non-scripted Porcelain is not required to use these messages
+ * and in fact are encouraged to reword them to better suit their particular
+ * situation better.  See how "git checkout" replaces not_uptodate_file to
+ * explain why it does not allow switching between branches when you have
+ * local changes, for example.
+ */
+static struct unpack_trees_error_msgs unpack_plumbing_errors = {
 	/* would_overwrite */
 	"Entry '%s' would be overwritten by merge. Cannot merge.",
 
@@ -28,7 +36,7 @@ static struct unpack_trees_error_msgs unpack_default_errors = {
 #define ERRORMSG(o,fld) \
 	( ((o) && (o)->msgs.fld) \
 	? ((o)->msgs.fld) \
-	: (unpack_default_errors.fld) )
+	: (unpack_plumbing_errors.fld) )
 
 static void add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
 	unsigned int set, unsigned int clear)
#16 lore raw

Re: Re* [PATCH] "not uptodate" changed to "has local changes"

In reply to Junio C Hamano
Quoted 1 line · Junio C Hamano

Why does *everybody* keep missing the whole point of this patch?

Isn't it to make it possible to change the error messages at porcelain level while allowing the plumbing to remain backward compatibility?

Signature · 3 lines
Cheers,

Sverre Rabbelier
#17 lore raw

Re: Re* [PATCH] "not uptodate" changed to "has local changes"

In reply to Junio C Hamano
Quoted 1 line · Junio C Hamano

Don't feed the troll by responding to a cheap shot.

Yes, a cheap shot, but I think one trying to make a point.

Quoted 6 lines

The plumbing output is sacred as it is an API. We _could_ change it if it is broken in such a way that it cannot convey necessary information fully, but we just do not _reword_ for the sake of rewording. If somebody does not like it, s/he is complaining too late. S/he should have been here in early May 2005 and make the language used by the API closer to what humans read. S/he wasn't here. Too bad, and it is too late.

Mhh.. I guess I didn't realize how strongly git still is "many commands that are good at what they do" that together form a coherent entity.

Quoted 3 lines

If you do not see something wrong with this output, your brain has already been rotten with use of git for too long a time. Nobody asked us to "merge" but why are we talking about "Cannot merge"?

Very good point, perhaps we should consider double-checking them all and improving them for one of the next 1.x releases.

Quoted 9 lines

Try a different approach along this patch instead.

   $ git-checkout pu
   error: You have local changes to 'Makefile'; cannot switch branches.

There are other places that ask unpack_trees() to n-way merge, detect issues _and_ let it issue error message on its own, which people who complained in this thread can identify and improve, but I did this as a demonstration and replaced only one message.

The patch looks like a step in the right direction, but if there is interest in improving the error messaging system why not do it right and make it generic. Instead of each file reinventing the wheel create a more generic system that uses a configuration file (I think this was suggested earlier). If we choose something like that, perhaps it would be nice to add a 'scripting' mode, which provides with a CLI-like messages instead of the usual human-readable ones (and thus less easy to parse).

<snip patch>

Signature · 3 lines
Cheers,

Sverre Rabbelier
#18 lore raw
In reply to Sverre Rabbelier

Hi,

Quoted 5 lines · Sverre Rabbelier
Quoted 2 lines · Steven Walter

With this dedication to backwards-compatibility, we'll be at Windows Vista quality in no time.

That is silly at best, especially given that Vista is _not_ backwards-compatible. Not to mention that it is not forkable, because it is not Open Source.

Quoted 6 lines

I very much agree here, given the nature of scripts (that is, being very easy to update), I think we should try not to be too strict in backwards-compatibility or we'll lose the flexibility that is very much needed when developing a Good Product (tm) As long as such compatibility breaking changes are marked (in BIG LETTERS) in the changelog/release notes I think that would be a 'sacrifice' we should consider making.

Had you (one of our GSoc students) not replied, I would not even have bothered to say anything.

But I strongly disagree with the notion that it is okay to fsck with old-timers (who would be harmed by breaking backwards-incompatibility, and nobody else), especially given that it is mostly old-timers who turned Git into the Good Product(tm) it is.

Ciao,
Dscho

#19 lore raw

On Sat, May 17, 2008 at 8:44 PM, Johannes Schindelin > But I strongly disagree with the notion that it is okay to fsck with

Quoted 3 lines

old-timers (who would be harmed by breaking backwards-incompatibility, and nobody else), especially given that it is mostly old-timers who turned Git into the Good Product(tm) it is.

But those old-timers can be updated can't they? Also, shouldn't we have tests to see if they 'break' because of changes?

Signature · 3 lines
Cheers,

Sverre Rabbelier

A message that is not in the archive (sent off-list or not yet received): [email protected]

#21 lore raw
Quoted 1 line · しらいしななこ

What advantage are you bringing to the table for them to be worth bothering to update, other than "if they update then they can get their scripts working again after you break them by rewording messages for no good reason"? Why do you punish the old-timers for using the well established API?

My reason was that (perhaps not as much in this case, but I meant to speak in general) the message is confusing/not clear enough.

Quoted 1 line

Did you study Junio's patch before you responded to his message? The point of the suggestion was that he reworded the message given by git-checkout that is a porcelain command without breaking output from read-tree that is a plumbing command. In other words, you can improve output from porcelain commands without making unnecessary changes to plumbing.

I hadn't read his e-mail when I was replying, my Internet has been playing up lately (same for about half of the Netherlands due to a problem at one of our biggest ISPs). I did reply to it though:
http://thread.gmane.org/gmane.comp.version-control.git/81100

Signature · 3 lines
Cheers,

Sverre Rabbelier
#23 lore raw
Quoted 4 lines · Holger Schurig
Quoted 2 lines

No comment on the concern that it might break people's scripts? None?

Scripts should look for exit values :-)

except that they're not documented ;)

Signature · 1 line
Francis
#24 lore raw
In reply to Holger Schurig

Hi,

Quoted 4 lines · Holger Schurig
Quoted 2 lines

No comment on the concern that it might break people's scripts? None?

Scripts should look for exit values :-)

Clever. And which exit value would you exactly check to see _which_ file needs an update?

Hth,
Dscho