git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	git@vger.kernel.org, "Jeff King" <peff@peff.net>,
	"Will Palmer" <wmpalmer@gmail.com>
Subject: Re: [PATCH RFC] commit: allow to commit even if there are intent-to-add entries
Date: Wed, 11 Jan 2012 05:02:22 -0600	[thread overview]
Message-ID: <20120111110222.GA32173@burratino> (raw)
In-Reply-To: <7vr4z67jbb.fsf@alter.siamese.dyndns.org>

Hi,

Junio C Hamano wrote:

> I have a mild suspicion that in earlier incarnation of the patch we used
> to let empty blobs committed, and then we used to instead not commit
> anything at all for such a path, and the real users were bitten by either
> of these approaches, forgetting to add the contents to the final commit.

I remember the empty blob era. :)  I don't think I ever saw something
like this patch, though, and a quick search finds that the first
iteration of the bugfix to stop commiting empty blobs was the one that
was used:

 http://thread.gmane.org/gmane.comp.version-control.git/101881/focus=101894

I suspect that at the time, introducing an intent-to-add flag (which
was always the right thing to do) provided enough momentum to avoid
any worries about smaller details like whether to error out or skip
those entries on commit, which could always be changed later (today).

> So I am not sure if this is such a good idea.

My first reaction was the same, but on reflection, I think this is a
good idea as long as the "git status" output in the editor says
something appropriate.

The response Duy mentioned[1] to a report about the unenlightening
message "error building trees" was also memorable:

> When running "commit" and "status" with files marked with "intent to add",
> I think there are three possible interpretations of what the user
> wants to do.
[ (1) thanks for stopping me, I had forgotten about that file;
  (2) I changed my mind, please leave that file out; or (3) please
  dwim and add the file ]

I think (3) was a trick --- no one that does not use the "-a" option
would want that. :)

At the time, I did not understand what (2) meant.  Now I see why ---
in interpretation (2), the user did not change her mind at all.  She
said "I will be adding this file at some point, so please keep track
of it along with the others for the sake of commands like 'git diff'
and 'git add -u', but that does not mean "I will be adding this file
at some point _before the next commit_".

So at the time I thought (1) was the only sensible behavior but kept
my mouth shut; and now I see that (1) and (2) both fit into reasonable
workflows.

However.  A person using "git diff" to review remaining changes and
"git add" to mark files once they have reached their final form would
benefit even more from a switch for "git commit" to error out if _any_
files in the worktree do not match the index.  So if we are to take
this workflow seriously, treating "git add -N" as a special case is
not helping.  What we currently provide for this workflow is a
reminder in the status area of changes that were not marked with "git
add".

I suspect no longer erroring out might feel eerie for a period for
people that were relying on "git add -N" as a reminder but that as
long as the "git status" output is sensible enough, Duy's proposed
behavior would end up seeming just as natural.

(2) makes intent-to-add entries just like any other tracked index
entry with some un-added content.  It is conceptually pleasant and
fits well in all workflows I can imagine[2].

Hope that helps, and sorry for the ramble,
Jonathan

[1] http://thread.gmane.org/gmane.comp.version-control.git/170651/focus=170658
[2] Ok, that is a small lie.  In "git stash", a commit is used to save
the state of the index, so the user would want the presence of the
intent-to-add entry to be stored somehow in the commit, and none of
(1), (2), or (3) will make her happy.  Using "git commit" this way is
not going to work when there are unmerged entries, for example,
either, so I think it is okay to ignore that problem here.

  reply	other threads:[~2012-01-11 10:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11  6:01 [PATCH RFC] commit: allow to commit even if there are intent-to-add entries Nguyễn Thái Ngọc Duy
2012-01-11  8:08 ` Junio C Hamano
2012-01-11 11:02   ` Jonathan Nieder [this message]
2012-01-11 21:08     ` Junio C Hamano
2012-01-12  2:53       ` Nguyen Thai Ngoc Duy
2012-01-12  3:05         ` Junio C Hamano
2012-01-11  9:59 ` Nguyễn Thái Ngọc Duy
2012-01-11  9:59 ` [PATCH 1/2] cache-tree: update API to take abitrary flags Nguyễn Thái Ngọc Duy
2012-01-11 23:48   ` Junio C Hamano
2012-01-12  1:20     ` Nguyen Thai Ngoc Duy
2012-01-11  9:59 ` [PATCH 2/2] commit: add --skip-intent-to-add to allow commit with i-t-a entries in index Nguyễn Thái Ngọc Duy
2012-01-11 23:55   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120111110222.GA32173@burratino \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=wmpalmer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).