git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] refs.h: make all flags arguments unsigned

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 1, 2022, 02:02 UTC
Message-ID
<xmqqa6fbgx85.fsf@gitster.g>
In-Reply-To
<pull.1210.git.git.1643660136530.gitgitgadget@gmail.com>
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 6 quoted lines
> From: Han-Wen Nienhuys <hanwen@google.com>
>
> As discussed in
> https://lore.kernel.org/git/xmqqbkzrkevo.fsf@gitster.g/ , we don't
> want to treat the sign bit specially, so make all flags in refs.h
> unsigned.

It may be true that we do not want to, but are we sure there is no code that already uses some cleverness to make the topmost bit special by e.g. doing ugly things like "if (flags < 0)" ;-)?

IOW, what we want or do not want does not matter as much as what the code paths that use these declarations want to do (and we need to fix them before we can do this conversion).

I haven't had energy to vet the entire codebase for all flag words and that is why I've never produced a patch like this one myself.

Thanks for carefully vetting after creating this (presumably mechanically prepared) patch---producing is the easy part, but making sure it does not break unexpectedly is much harder.

Somebody other than the author needs to double check the result, though.

Thanks.
Show 54 quoted lines
>  bisect.c                    |  4 +--
>  builtin/bisect--helper.c    |  7 ++---
>  builtin/branch.c            |  4 +--
>  builtin/checkout.c          |  9 ++++---
>  builtin/describe.c          |  3 ++-
>  builtin/fetch.c             | 10 +++----
>  builtin/fsck.c              |  4 +--
>  builtin/gc.c                |  5 ++--
>  builtin/name-rev.c          |  3 ++-
>  builtin/pack-objects.c      | 11 ++++----
>  builtin/rebase.c            |  5 ++--
>  builtin/receive-pack.c      |  4 +--
>  builtin/reflog.c            |  5 ++--
>  builtin/remote.c            | 13 ++++++----
>  builtin/repack.c            |  4 +--
>  builtin/replace.c           |  4 +--
>  builtin/rev-parse.c         |  6 +++--
>  builtin/show-branch.c       |  6 ++---
>  builtin/show-ref.c          |  4 +--
>  builtin/stash.c             |  2 +-
>  builtin/submodule--helper.c |  4 +--
>  builtin/symbolic-ref.c      |  2 +-
>  bundle.c                    |  2 +-
>  commit-graph.c              |  5 ++--
>  config.c                    |  2 +-
>  delta-islands.c             |  2 +-
>  fetch-pack.c                |  7 ++---
>  help.c                      |  2 +-
>  http-backend.c              |  4 +--
>  log-tree.c                  |  4 +--
>  ls-refs.c                   |  4 +--
>  midx.c                      |  5 ++--
>  negotiator/default.c        |  2 +-
>  negotiator/skipping.c       |  2 +-
>  notes.c                     |  5 ++--
>  object-name.c               |  2 +-
>  reachable.c                 |  2 +-
>  ref-filter.c                |  3 ++-
>  refs.c                      | 52 ++++++++++++++++++-------------------
>  refs.h                      | 38 ++++++++++++---------------
>  refs/files-backend.c        | 17 ++++++------
>  remote.c                    | 10 +++----
>  replace-object.c            |  7 +++--
>  revision.c                  |  8 +++---
>  server-info.c               |  2 +-
>  shallow.c                   |  4 +--
>  submodule.c                 |  4 +--
>  t/helper/test-ref-store.c   |  4 +--
>  transport-helper.c          |  2 +-
>  transport.c                 |  2 +-
>  upload-pack.c               |  8 +++---
>  walker.c                    |  2 +-
>  worktree.c                  |  6 ++---
>  53 files changed, 171 insertions(+), 167 deletions(-)
Previous: Han-Wen Nienhuys via GitGitGadgetNext: Han-Wen Nienhuys
Message 2 of 17 in “refs.h: make all flags arguments unsigned”
  1. refs.h: make all flags arguments unsignedHan-Wen Nienhuys via GitGitGadget, Jan 31, 2022
  2. Junio C HamanoFeb 1, 2022
  3. Han-Wen NienhuysFeb 1, 2022
  4. Junio C HamanoFeb 1, 2022
  5. refs.h: make all flags arguments unsignedHan-Wen Nienhuys via GitGitGadget, Feb 1, 2022
  6. Ævar Arnfjörð BjarmasonFeb 1, 2022
  7. Junio C HamanoFeb 1, 2022
  8. Han-Wen NienhuysFeb 3, 2022
  9. Ævar Arnfjörð BjarmasonFeb 3, 2022
  10. Han-Wen NienhuysFeb 3, 2022
  11. Ævar Arnfjörð BjarmasonFeb 3, 2022
  12. Junio C HamanoFeb 3, 2022
  13. Han-Wen NienhuysFeb 3, 2022
  14. Junio C HamanoFeb 3, 2022
  15. 0/2 refs.h: make all flags arguments unsignedHan-Wen Nienhuys via GitGitGadget, Feb 3, 2022
  16. 1/2 refs.h: make all flags arguments unsignedHan-Wen Nienhuys via GitGitGadget, Feb 3, 2022
  17. 2/2 Uniformize flag argument naming to `flags` or `unused_flags`Han-Wen Nienhuys via GitGitGadget, Feb 3, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.