Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-37767: [C++][CMake] Don't touch .git/index #38003

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

kou
Copy link
Member

@kou kou commented Oct 4, 2023

Rationale for this change

We run "git describe --tag --dirty" implicitly in
cpp/cmake_modules/DefineOptions.cmake. If we use "--dirty", .git/index's owner may be changed. Because "git describe" touches .git/index for "--dirty".

We can avoid changing .git/index's owner by not using "--dirty".

What changes are included in this PR?

Remove "--dirty".

Are these changes tested?

Yes. I used "strace git describe ...".

Are there any user-facing changes?

No.

We run "git describe --tag --dirty" implicitly in
cpp/cmake_modules/DefineOptions.cmake. If we use "--dirty",
.git/index's owner may be changed. Because "git describe" touches
.git/index for "--dirty".

We can avoid changing .git/index's owner by not using "--dirty".
@github-actions
Copy link

github-actions bot commented Oct 4, 2023

⚠️ GitHub issue #37767 has been automatically assigned in GitHub to PR creator.

@@ -747,7 +747,7 @@ if(NOT ARROW_GIT_ID)
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if(NOT ARROW_GIT_DESCRIPTION)
execute_process(COMMAND "git" "describe" "--tags" "--dirty"
execute_process(COMMAND "git" "describe" "--tags"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this fixes the issue reliably? Is it just an implementation detail in git?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an implementation detail.

The git describe document doesn't explain this behavior: https://git-scm.com/docs/git-describe

Here is the implementation with --dirty:

https://github.com/git/git/blob/3a06386e314565108ad56a9bdb8f7b80ac52fb69/builtin/describe.c#L669-L697

It touches .git/index (*_index() functions are used).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow great investigation!

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Oct 9, 2023
Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from me

@pitrou pitrou requested a review from assignUser October 10, 2023 08:48
@assignUser assignUser merged commit 277b168 into apache:main Oct 11, 2023
@assignUser assignUser removed the awaiting changes Awaiting changes label Oct 11, 2023
@kou kou deleted the cpp-cmake-not-touch-git-index branch October 11, 2023 02:48
@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit 277b168.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them.

JerAguilon pushed a commit to JerAguilon/arrow that referenced this pull request Oct 23, 2023
### Rationale for this change

We run "git describe --tag --dirty" implicitly in
cpp/cmake_modules/DefineOptions.cmake. If we use "--dirty", .git/index's owner may be changed. Because "git describe" touches .git/index for "--dirty".

We can avoid changing .git/index's owner by not using "--dirty".

### What changes are included in this PR?

Remove "--dirty".

### Are these changes tested?

Yes. I used "strace git describe ...".

### Are there any user-facing changes?

No.
* Closes: apache#37767

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Jacob Wujciak-Jens <[email protected]>
loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
### Rationale for this change

We run "git describe --tag --dirty" implicitly in
cpp/cmake_modules/DefineOptions.cmake. If we use "--dirty", .git/index's owner may be changed. Because "git describe" touches .git/index for "--dirty".

We can avoid changing .git/index's owner by not using "--dirty".

### What changes are included in this PR?

Remove "--dirty".

### Are these changes tested?

Yes. I used "strace git describe ...".

### Are there any user-facing changes?

No.
* Closes: apache#37767

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Jacob Wujciak-Jens <[email protected]>
dgreiss pushed a commit to dgreiss/arrow that referenced this pull request Feb 19, 2024
### Rationale for this change

We run "git describe --tag --dirty" implicitly in
cpp/cmake_modules/DefineOptions.cmake. If we use "--dirty", .git/index's owner may be changed. Because "git describe" touches .git/index for "--dirty".

We can avoid changing .git/index's owner by not using "--dirty".

### What changes are included in this PR?

Remove "--dirty".

### Are these changes tested?

Yes. I used "strace git describe ...".

### Are there any user-facing changes?

No.
* Closes: apache#37767

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Jacob Wujciak-Jens <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[C++] C++ build sometimes changes .git ownership
3 participants