[PATCH v3 0/2] diff: index-line: respect --abbrev in object's name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For diff-family, Git supports 2 different options for 2 different
purposes, `--full-index' for showing diff-patch object's name in full,
and `--abbrev' to customize the length of object names in diff-raw and
diff-tree header lines, without any options to customise the length of
object names in diff-patch format. When working with diff-patch format,
we only have two options, either full index, or default abbrev length.

Although, that consistent is documented, it doesn't stop users from
trying to use `--abbrev' with the hope of customising diff-patch's
objects' name's abbreviation.

Let's resolve that inconsistency.

Đoàn Trần Công Danh (2):
  revision: differentiate if --no-abbrev asked explicitly
  diff: index-line: respect --abbrev in object's name

 Documentation/diff-options.txt                |  9 +++---
 diff.c                                        |  5 +++-
 revision.c                                    |  2 +-
 t/t4013-diff-various.sh                       |  3 ++
 ...ff.diff-tree_--root_-p_--abbrev=10_initial | 29 +++++++++++++++++++
 ...--root_-p_--full-index_--abbrev=10_initial | 29 +++++++++++++++++++
 ...f.diff-tree_--root_-p_--full-index_initial | 29 +++++++++++++++++++
 7 files changed, 100 insertions(+), 6 deletions(-)
 create mode 100644 t/t4013/diff.diff-tree_--root_-p_--abbrev=10_initial
 create mode 100644 t/t4013/diff.diff-tree_--root_-p_--full-index_--abbrev=10_initial
 create mode 100644 t/t4013/diff.diff-tree_--root_-p_--full-index_initial

Range-diff against v2:
1:  9daef7445c ! 1:  9a26c5b611 revision: differentiate if --no-abbrev asked explicitly
    @@ Metadata
      ## Commit message ##
         revision: differentiate if --no-abbrev asked explicitly
     
    -    When we see `--no-abbrev' in command's arguments, we reset `abbrev' of
    -    `diff_options` to 0, thus, on a later stage, the object id won't
    -    be shortened (by not set object_id[abbrev] to '\0').
    +    When we see --no-abbrev in command's arguments, we reset the 'abbrev'
    +    field in diff-options to 0 and this value will be looked at
    +    diff_abbrev_oid() to decide not to truncate the object name.
    +
    +    In a later change, we want to extend --abbrev support to diff-patch
    +    format. When --abbrev supporting diff-patch, we need to differentiate
    +    those below scenarios:
    +
    +    * None of those options --abbrev, --no-abbrev, and --full-index are
    +      asked. diff-patch should keep old behavior of using DEFAULT_ABBREV
    +      for the index length.
    +    * --no-abbrev is asked, diff-patch should treat this option as same as
    +      --full-index and show full object name in index line.
     
         While not doing anything is very effective way to show full object id,
         we couldn't differentiate if --no-abbrev or not.
     
    -    In a later change, we want to extend --abbrev support to diff-patch
    -    format.
    +    We can differentiate those above scenarios by either:
    +    * Add a new field in diff-options to mark if --no-abbrev was asked.
    +      With this option, we have a new field for a single purpose, and one
    +      more thing to worry about.
    +    * Treat --no-abbrev as same as --full-index. This option is problematic,
    +      since we want to allow --abbrev overwrite --no-abbrev again.
    +      On the other hand, we also need to keep our promises with scripter
    +      who uses --full-index to ask for full object names in index line,
    +      so, we need to respsect --full-index regardless of --abbrev.
    +    * Set 'abbrev' field in diff-options to the length of the hash we are
    +      using. With this option, we can differentiate if --no-abbrev was asked
    +      ('abbrev' is hash's length) or none of --[no-]abbrev was asked
    +      ('abbrev' is '0'), script with --full-index still works and our
    +      headache is kept as is.
     
    -    Let's ask for full object id if we see --no-abbrev instead.
    +    Let's ask for full object id if we see --no-abbrev.
     
         Signed-off-by: Đoàn Trần Công Danh <congdanhqx@xxxxxxxxx>
     
2:  12acf1fe5d = 2:  760df7782d diff: index-line: respect --abbrev in object's name
-- 
2.28.0.215.g32ffa52ee0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux