← Back to Blog List

Microproject Review: Iterating on Patches and Commit Style

Based on initial feedback regarding commit granularity, the next step involved restructuring the proposed changes to MyFirstContribution.adoc into a logical patch series suitable for review according to Git project standards.

Revised Submission: Patch Series Structure (V2/V3)

The original single commit was decomposed using `git rebase -i` into three distinct patches, aiming for atomic changes:

  • Patch 1/3: Focused on removing the defunct mentoring mailing list reference and adding a note about C language prerequisites.
  • Patch 2/3: Addressed the update of the `cmd_psuh` function signature to include `struct repository *repo` and introduced the `UNUSED` macro for unused parameters, including the corresponding change in `builtin.h`.
  • Patch 3/3: Concentrated on replacing the `git_config(...)` function calls with `repo_config(...)` in the documentation examples.

(Note: Commit subjects evolved across versions V2 and V3 based on review).

This series was formatted using `git format-patch` and submitted to the mailing list. A corresponding GitHub PR was also opened, primarily intended for utilizing CI checks, although subsequent discussion clarified this wasn't strictly necessary for a mailing-list-based workflow.

Technical Review and Style Conventions (Feedback on V2/V3)

Junio Hamano provided detailed feedback on the V2/V3 submissions (viewable here), primarily concerning commit message formatting and adherence to Git's coding and documentation conventions.

Commit Message Structure:

Specific guidance was given regarding the structure outlined in `Documentation/SubmittingPatches`:

Key takeaways included the requirement for a concise, prefixed subject line (e.g., `doc: ` or `MyFirstContribution: `) without a trailing period, clearly separated from the commit body by a blank line.

Documentation Formatting:

A line added in Patch 1/3 exceeded the conventional line length for documentation:

Maintaining reasonable line lengths (typically ~70-76 characters) is important for readability across different display environments.

Clarity of Commit Justification (V3 Patch 2/3):

The rationale for updating the function signature required clearer justification than "for better compatibility":

Effective commit messages should precisely explain the 'why' behind a change, often linking it to specific previous commits or architectural shifts in the codebase.

Coding Style in Examples (V3 Patch 3/3):

The use of C++ style comments (`//`) within a C code example was flagged:

#include "repository.h"  // Required for repo_config_get_string_tmp()

This highlighted the need for examples within documentation to adhere to the project's primary coding style (C89, using `/* C-style comments */`).

Refinement and Further Discussion (V4)

A V4 patch series was prepared incorporating the feedback on commit messages, line wrapping, and comment style. The C++ style comment was removed from the example code.

This led to further discussion regarding the explanation of `#include` directives in tutorials. Junio suggested that simply adding headers in examples isn't as beneficial as explaining *why* they are necessary within the preceding text, especially for a tutorial:

This presented a question of scope and consistency. The existing document lacked detailed explanations for most header inclusions. Adding detailed reasoning only for the headers modified in this patch series could create inconsistency. The options considered were:

  1. Address the formatting/style issues in the current V4 patches and defer consistent, detailed header explanations across the document to a potential separate effort.
  2. Modify the current V4 Patch 3/3 to include a detailed explanation specifically for `repository.h`.
  3. Maintain the current minimal explanation in V4, aligning with the existing style of the document.

Current Technical Status

The discussion regarding the optimal level of detail for explaining header includes within this specific tutorial context remains open pending further direction. A follow-up email was sent to seek clarification on proceeding with one of the outlined options.

The review process for this microproject involved multiple iterations, focusing significantly on adherence to Git's established standards for commit messages, documentation formatting, coding style within examples, and the clarity of technical justifications. This underscores the importance of precise communication and formatting conventions in maintaining a large, collaborative codebase like Git.