Re: [git-users] Re: Documentation discrepancy

2012-06-26 Thread Konstantin Khomoutov
On Mon, 25 Jun 2012 22:23:35 -0700 (PDT)
Git User  wrote:

> Thanks again.
> 
> It seems I didn't express myself clearly. OK, let me elaborate on
> specific examples:
[...]

Sorry, have no time to read thoroughly at the moment -- will come back
to it later and try to grasp.

>  If it's too cumbersome an explanation, could you please tell me how
> to see which plumbing commands are executed with a specified
> porcelain command (something like a trace or debug feature)? I could
> have then decomposed `git commit' and `git commit file' into
> low-level commands and craft my own porcelain command based on those
> plumbing commands.
Export GIT_TRACE=1 before running Git commands; like

$ export GIT_TRACE=1
$ git commit ...

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Documentation discrepancy

2012-06-26 Thread Git User
Thanks a lot everyone.
Finally figured it out.
I think that the following command sequence will do the trick:
 
cp file file.unstaged
git co file
git commit file
mv file.unstaged file
I'll try to do a wrapper (`git-commit-staged' for example) and extend it on 
the case of multiple files.
 

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/-jSDM6GoYU8J.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Documentation discrepancy

2012-06-26 Thread Thomas Ferris Nicolaisen
Usually, the whole index is committed as an indivisible unit. The trick of 
git commit  is that it avoids using the index completely. It goes 
straight from work-tree (file) to repository (blob), as far as I can 
understand. From the docs of git commit 
:

3. by listing files as arguments to the commit command, in which 
case the commit will ignore changes staged
   in the index, and instead record the current content of the 
listed files (which must already be known to
   git);

I'm not sure if there is a way to achieve what you want without writing 
some C, and create a temporary index on the fly or something.. 

By the way, you may find this chapter of the Git book 
interesting: http://git-scm.com/book/en/Git-Internals-Git-Objects - some 
details on plumbing there.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/yeD34G4cX2MJ.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Documentation discrepancy

2012-06-25 Thread Git User
 

Thanks again.

It seems I didn't express myself clearly. OK, let me elaborate on specific 
examples:


 *Scenario 1:*


 *$ cat>a.txt *

alpha 

*$ git add a.txt *

*$ cat>>a.txt *

beta 

*$ git st *

# On branch master 

# Changes to be committed: 

# (use "git reset HEAD ..." to unstage) 

# 

# new file: a.txt 

# 

# Changed but not updated: 

# (use "git add ..." to update what will be committed) 

# (use "git checkout -- ..." to discard changes in working directory) 

# 

# modified: a.txt 

# 

*$ git ci -m 'add a.txt' *

*$ git st *

# On branch master 

# Your branch is ahead of 'origin/master' by 1 commit. 

# 

# Changed but not updated: 

# (use "git add ..." to update what will be committed) 

# (use "git checkout -- ..." to discard changes in working directory) 

# 

# modified: a.txt 

# 

no changes added to commit (use "git add" and/or "git commit -a") 


 OK, that's clear. Next:


 *Scenario 2:*


 *$ cat>b.txt *

gamma 

*$ git add b.txt *

*$ cat>c.txt *

delta 

*$ git add c.txt *

*$ cat>>b.txt *

epsilon 

*$ cat>>c.txt *

zeta 

*$ git st *

# On branch master 

# Changes to be committed: 

# (use "git reset HEAD ..." to unstage) 

# 

# new file: b.txt 

# new file: c.txt 

# 

# Changed but not updated: 

# (use "git add ..." to update what will be committed) 

# (use "git checkout -- ..." to discard changes in working directory) 

# 

# modified: b.txt 

# modified: c.txt 

# 


Up till now it's also clear. Then we do:

*
*

*$ git ci -m 'add c.txt' c.txt *

*$ git st *

# On branch master 

# Your branch is ahead of 'origin/master' by 1 commit. 

# 

# Changes to be committed: 

# (use "git reset HEAD ..." to unstage) 

# 

# new file: b.txt 

# 

# Changed but not updated: 

# (use "git add ..." to update what will be committed) 

# (use "git checkout -- ..." to discard changes in working directory) 

# 

# modified: b.txt 

# 


>From the output of the above command I can conclude that b.txt, although 
having staged (as well as unstaged) changes, preserves its state exactly as 
it was before last commit, so git left other files except c.txt 'as-is'.

To sum it up:

«Scenario 1» tells that git lets us commit staged changes and preserves 
unstaged changes of a file.

«Scenario 2» tells that git lets us commit only selected files from the 
index, and leave other files 'as-is'.

What prevents us from combining these two behaviours, so that we could 
commit only selected files from the index, preserving their unstaged 
changes, as well as leaving other files 'as-is'?


 If it's too cumbersome an explanation, could you please tell me how to see 
which plumbing commands are executed with a specified porcelain command 
(something like a trace or debug feature)? I could have then decomposed 
`git commit' and `git commit file' into low-level commands and craft my own 
porcelain command based on those plumbing commands.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/sqL98mmgvckJ.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Documentation discrepancy

2012-06-25 Thread Konstantin Khomoutov
On Sun, 24 Jun 2012 18:46:03 -0700 (PDT)
Git User  wrote:

> Thanks to everyone.
> Just one more thing:
> If we could exclude that `git add file' part from `git commit file',
> we would get the desired behavior, wouldn't we?
> It seems to me like `git commit --staget file' is a subset of the
> operation `git commit file'.
> Or I'm wrong ?
You seem to be wrong.
Seems like you did not grasp the concept of the Git staging area.

Git is different to many (all?) mainstream DVCSes in that it cuts its
commits not from your work tree but from a special "virtual" area
called "the index" or "the staging area" (earlier in Git's life it was
also called "the cache").
Initially the index is empty, you then do local modification to your
files and record *just those changes you want to be committed* by using
`git add `.  When you subsequently call `git commit`, it's
the state currently maintained in index that gets committed, not the
changes in your work tree.

Alternatively it might turn out that you've been trained by some sloppy
person to always use `git commit -a` which means (`git add -u` + `git
commit`).

So supposedly what you should use to achieve your original goal, is to
just `git add` the only file you need (to stage for committing only
those file's changes), do not add any other changed files and then
commit.  The resulting commit will contain only the changes made
to that single file.

Note that `git add` supports one super-handy option, "--patch", which
even allows you to interactively pick single changes from the locally
modified file and stage for commiting only those you want leaving other
changes intact.

One good introductory read on this matter is the first part of [1].

1. http://git-scm.com/2011/07/11/reset.html

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Documentation discrepancy

2012-06-24 Thread Git User
Thanks to everyone.
Just one more thing:
If we could exclude that `git add file' part from `git commit file', we 
would get the desired behavior, wouldn't we?
It seems to me like `git commit --staget file' is a subset of the operation 
`git commit file'.
Or I'm wrong ?

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/tUzm9M89sGAJ.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Documentation discrepancy

2012-06-24 Thread Philip Oakley

From: "Konstantin Khomoutov" 
To: 
Cc: "Git User" 
Sent: Friday, June 22, 2012 2:40 PM
Subject: Re: [git-users] Re: Documentation discrepancy



On Thu, 21 Jun 2012 18:06:29 -0700 (PDT)
Git User  wrote:


Thank you.
Here is what I meant:
echo alpha > a.txt
add a.txt
echo beta > b.txt
add b.txt
echo gamma >> b.txt

Now I have a.txt and b.txt in staged state; and b.txt also has
unstaged changes.
I want to commit ONLY b.txt (i.e. I want to commit only 'beta' and
leave b.txt in modified state with 'beta' & 'gamma' in it, 'gamma'
being showed as '+gamma' in `git diff'.
Something like `git commit --staged b.txt'
In other words, how do we `git commit' just one file from the index
if there are more than one files in the index.


I think you can't as you effectively wish to have one more level of
indirection (the second index).

I can imagine various workarounds to achieve what you want but they 
all

are imperfect in one way or another.

The proper way to do this probably would be to write your own 
porcelain

command that would:
1) Save a list of files with staged changes.
2) Reset all of the staged entries except for those files you 
specified.

  If any file to reset has unstaged local changes, refuse to proceed.
3) Commit.
4) Re-add the files that were reset on step (2).


@Git User:
Also have a look at what `git stash` can do for you in terms of taking a 
snapshot of your current 'dirty' working tree and then giving you a 
chance to checkout any commit or branch  you wanted, and pick stuff out 
of the stash to create the commit wou want, and then pop the stash.


Philip 


--
You received this message because you are subscribed to the Google Groups "Git for 
human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Documentation discrepancy

2012-06-22 Thread Konstantin Khomoutov
On Thu, 21 Jun 2012 18:06:29 -0700 (PDT)
Git User  wrote:

> Thank you.
> Here is what I meant:
> echo alpha > a.txt
> add a.txt
> echo beta > b.txt
> add b.txt
> echo gamma >> b.txt
> 
> Now I have a.txt and b.txt in staged state; and b.txt also has
> unstaged changes.
> I want to commit ONLY b.txt (i.e. I want to commit only 'beta' and
> leave b.txt in modified state with 'beta' & 'gamma' in it, 'gamma'
> being showed as '+gamma' in `git diff'.
> Something like `git commit --staged b.txt'
> In other words, how do we `git commit' just one file from the index
> if there are more than one files in the index.

I think you can't as you effectively wish to have one more level of
indirection (the second index).

I can imagine various workarounds to achieve what you want but they all
are imperfect in one way or another.

The proper way to do this probably would be to write your own porcelain
command that would:
1) Save a list of files with staged changes.
2) Reset all of the staged entries except for those files you specified.
   If any file to reset has unstaged local changes, refuse to proceed.
3) Commit.
4) Re-add the files that were reset on step (2).

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Documentation discrepancy

2012-06-21 Thread Git User
Thank you.
Here is what I meant:
echo alpha > a.txt
add a.txt
echo beta > b.txt
add b.txt
echo gamma >> b.txt

Now I have a.txt and b.txt in staged state; and b.txt also has unstaged 
changes.
I want to commit ONLY b.txt (i.e. I want to commit only 'beta' and leave 
b.txt in modified state with 'beta' & 'gamma' in it, 'gamma' being showed 
as '+gamma' in `git diff'.
Something like `git commit --staged b.txt'
In other words, how do we `git commit' just one file from the index if 
there are more than one files in the index.

>
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/2X4cpPI1VccJ.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Documentation discrepancy

2012-06-21 Thread Konstantin Khomoutov
On Wed, 20 Jun 2012 18:52:52 -0700 (PDT)
Git User  wrote:

[...]
> One more question.
> Is there an option to commit only specified files in their staged
> state without doing `git add' on them ?
There's a contradiction in your question: "the staged state" is
the state of the files as recorded in the staged area (in the index),
and the current (as in the work tree) state of files gets recorded in
the index by doing `git add` on those files.

A simple example (suppose the aaa.txt file did not exist):

$ echo one > aaa.txt
$ git add aaa.txt

At this point, aaa.txt is recorded in the index.
It's staged state is no different than its current state.

$ echo two >> aaa.txt

At this point, the staged state of aaa.txt is different
from its current state as this file has been modified
in the work tree, but the changes were not recorded.

If you do `git commit` at this point, the staged state will be
recoded, not the current stage (what's in the work tree).

P.S.
I also can imagine that you actually wanted to ask "is there a way to
commit the state of a set of files as present in the work tree without
going through adding them to the index?".  If this is indeed the case,
then the answer is "yes".
First, you can use
$ git commit --  [ ...]
which will effectively do `git add` on the specified files and then
commit the changes.
Second, you can do `git add -u` to record changes in all tracked files
to the index.
Third, you can do
$ git commit -a
which effectively is `git add -u` + `git commit`.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



[git-users] Re: Documentation discrepancy

2012-06-20 Thread Git User
Ok, thank you.
I think it would be less confusing this way:
"... ignore changes staged in the index ... -> `git add ' and then commit"

One more question.
Is there an option to commit only specified files in their staged
state without doing `git add' on them ?

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.