Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how is a diff pathspec defined

Tags:

git

diff

In gitdiffcore(7) it simply states:

The pathspecs are used to limit the world diff operates in. 
They remove the filepairs outside the specified sets of pathnames. 
E.g. If the input set of filepairs included:

    :100644 100644 bcd1234... 0123456... M junkfile

My question is how to read this, i.e. which fields are which, and what should they represent?

I'm looking so that I can understand if there is any mileage in detecting pathname changes (as an option) separately from the file rename detection which is both expensive and tends to suggest to users that many files have been renamed (rather than a single path change)

like image 916
Philip Oakley Avatar asked Sep 22 '26 09:09

Philip Oakley


1 Answers

let's break this down:

:100644        100644         bcd1234...     0123456...     M         junkfile
old file mode  new file mode  old file hash  new file hash  modified  file name

to create archives with a given name from a directory at a specified commit, use the git archive command:

git archive --prefix='your_product_v1.2/' -o 'your_product.zip' v1.2:path/to/directory/

assuming, you want to create an archive from path/to/directory/ as it was in version v.1 (tag, branch, you can even use a commit id here). the archive will be named your_product.zip (format inferred from file name, .tar is also possible), and all files will be placed in the subfolder your_product_v1.2 inside the zip file.

this way you don't have to rename the directory inside your VCS (why would you do that anyways?). hope that helps! leave a comment if things are still unclear.

like image 149
knittl Avatar answered Sep 24 '26 00:09

knittl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!