All of lore.kernel.org
 help / color / mirror / Atom feed
* Strange diff-index output
@ 2015-11-02 23:59 Ch'Gans
  2015-11-03  0:27 ` David Turner
  0 siblings, 1 reply; 4+ messages in thread
From: Ch'Gans @ 2015-11-02 23:59 UTC (permalink / raw)
  To: git

Hi there,

We're using a script to verify that what we are building is clean
against our git repository, for this we're using "git rev-parse
--short HEAD" to get the current hash and "git diff-index --quiet
HEAD" to check for local modification.
This script works fine on developer's machines, but doesn't on our CI
system (Atlassian Bamboo/Stash).

HEAD points to refs/heads/FIX-XYZ and refs/heads/FIX-XYZ exists.

On our CI, the output of diff-index gives something like:
:100644 100644 abcdef 000000 M file1

Our problem is very likely related with how Bamboo works and/or how we
use it, but to investigate this issue further, I first would like to
understand the meaning of the above output.

>From the man page of diff-index:
- 100644 is the mode of "src"
- 100644 is the mode of dst
- abcdef is the hash of src
- 000000 is the hash of dst
- M stands for "Modified"
- file1 is the filename being considered.

>From my understanding, src here means the file system and dst the git
object. So the above should mean "file1" is new and out of sync with
the index, which doesn't make sense since "file1" is definitely in the
repository. The weird stuff is that diff-index report the same problem
on every single file no just a few!

Notes:
 - Something I've noticed with Bamboo is that the cloned repository
doesn't have any remotes. Although I'm not sure if it is relevant
here.
 - I have tried with "shallow copy" Bamboo option enabled or not and I
get the same problems
 - I have tried "git update-index", but still get the same results
 - git log still gives me the full log history (but no remote heads)
 - git status reports nothing else than a couple of generated files
 - git status HEAD reports that the working directory is clean
 - git diff-index --cached reports nothing

Does any of you have ever come across this kind of problem? Could
anyone shed some light on what's going on with our clone? Any
documentation point out or hints appreciated.

Thanks,
Chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Strange diff-index output
  2015-11-02 23:59 Strange diff-index output Ch'Gans
@ 2015-11-03  0:27 ` David Turner
  2015-11-03  1:00   ` Ch'Gans
  0 siblings, 1 reply; 4+ messages in thread
From: David Turner @ 2015-11-03  0:27 UTC (permalink / raw)
  To: Ch'Gans; +Cc: git

On Tue, 2015-11-03 at 12:59 +1300, Ch'Gans wrote:
> Hi there,
> 
> We're using a script to verify that what we are building is clean
> against our git repository, for this we're using "git rev-parse
> --short HEAD" to get the current hash and "git diff-index --quiet
> HEAD" to check for local modification.

See this note from the git diff-index man page:
           Note
           As with other commands of this type, git diff-index does not
           actually look at the contents of the file at all. So maybe
           kernel/sched.c hasn’t actually changed, and it’s just that
you
           touched it. In either case, it’s a note that you need to git
           update-index it to make the index be in sync.

You can either add an update-index to your script, or use git status
--porcelain.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Strange diff-index output
  2015-11-03  0:27 ` David Turner
@ 2015-11-03  1:00   ` Ch'Gans
  2015-11-04  6:38     ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Ch'Gans @ 2015-11-03  1:00 UTC (permalink / raw)
  To: David Turner; +Cc: git

On 3 November 2015 at 13:27, David Turner <dturner@twopensource.com> wrote:
> On Tue, 2015-11-03 at 12:59 +1300, Ch'Gans wrote:
>> Hi there,
>>
>> We're using a script to verify that what we are building is clean
>> against our git repository, for this we're using "git rev-parse
>> --short HEAD" to get the current hash and "git diff-index --quiet
>> HEAD" to check for local modification.
>
> See this note from the git diff-index man page:
>            Note
>            As with other commands of this type, git diff-index does not
>            actually look at the contents of the file at all. So maybe
>            kernel/sched.c hasn’t actually changed, and it’s just that
> you
>            touched it. In either case, it’s a note that you need to git
>            update-index it to make the index be in sync.
>
> You can either add an update-index to your script, or use git status
> --porcelain.

Hi David,

I first tried "git update-index" but it didn't work. However "git
update-index --refresh" seems to fix our problem.
I didn't get why "--refresh" is needed thought, I'm really not
familiar with the caching aspect of git.
Anyway, I think that this fix is what I need right now.

Thanks,
Chris

>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Strange diff-index output
  2015-11-03  1:00   ` Ch'Gans
@ 2015-11-04  6:38     ` Jeff King
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2015-11-04  6:38 UTC (permalink / raw)
  To: Ch'Gans; +Cc: David Turner, git

On Tue, Nov 03, 2015 at 02:00:33PM +1300, Ch'Gans wrote:

> I first tried "git update-index" but it didn't work. However "git
> update-index --refresh" seems to fix our problem.
> I didn't get why "--refresh" is needed thought, I'm really not
> familiar with the caching aspect of git.

It is because update-index is a general command for manipulating the
index. For example, you can add, delete, or change entries without
regard to what is in the working tree.

One of the manipulations is "refresh the index based on what is in the
working tree", and that is spelled "--refresh". Most porcelain-level git
commands (like "git diff") will do this for you automatically and
transparently. But when using the scriptable plumbing (like diff-index),
git gives you more control. This lets you do things more efficiently
(e.g,. you might refresh once and then issue several low-level
commands), at the cost of convenience.

You could also have used "git diff-index --cached HEAD", which instructs
diff-index not to look at the working tree at all (so you would compare
whatever is in the index, whether it is up to date with what is in the
working tree or not). Depending on what you are trying to achieve, that
might be fine (it's also more efficient in general, as it does not
require an lstat() of every file in the working tree).

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-04  6:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-02 23:59 Strange diff-index output Ch'Gans
2015-11-03  0:27 ` David Turner
2015-11-03  1:00   ` Ch'Gans
2015-11-04  6:38     ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.