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

Please define some terms in Git - Git Hooks #1911

Open
PostalMike opened this issue Nov 2, 2023 · 1 comment
Open

Please define some terms in Git - Git Hooks #1911

PostalMike opened this issue Nov 2, 2023 · 1 comment

Comments

@PostalMike
Copy link

PostalMike commented Nov 2, 2023

I'm not new to Git. I'm studying the subject deeper, in the process I've run into some terms I can't find definitions or descriptions for.

From this page "The hooks are all stored in the hooks subdirectory of the Git directory. In most projects, that’s .git/hooks. When you initialize a new repository with git init, Git populates the hooks directory with a bunch of example scripts, many of which are useful by themselves; but they also document the input values of each script. "

What is documenting what, and what input values are being referred to? What does "they" refer to in the phrase "but they also document the input values of each script"?

Further down the page: "The pre-commit hook is run first, before you even type in a commit message. It’s used to inspect the snapshot that’s about to be committed, to see if you’ve forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code. Exiting non-zero from this hook aborts the commit, although you can bypass it with git commit --no-verify. "

What is "exiting non-zero"? I kind of get it -- in TSQL if one gets a message with a non-zero code it means there's a problem. "Zero" in this case would mean one wants the commit to happen, so "non-zero" means there's a problem and one doesn't want the commit to happen? This is a bit of a stretch, obviously.

This may be a silly question -- but what exactly does "hook" mean here? In marketing it's what gets a person's attention. In music, it's what gets and keeps audience members interested. "Hook" in software seems a misnomer. Really, it's a glorified API call, right? I found a good definition here "A hook in software development refers to a mechanism that allows developers to extend or modify an existing application's behavior by injecting custom code." This seems to fit the context of Git Hooks

Sorry if some of this appears nit-ish. But I'd really love to finally "get the hook" , just in a good way :).

@yjhn
Copy link

yjhn commented Apr 28, 2024

What is documenting what, and what input values are being referred to? What does "they" refer to in the phrase "but they also document the input values of each script"?

"They" refers to the example scripts. These scripts contain documentation of arguments (if any) that are supplied by Git when a specific script is called.

What is "exiting non-zero"?

E. g. exit 1 in a shell script. When any process exits (i. e. terminates), it returns back a single int value. Return value 0 means "everything OK", while any non-zero value (commonly 1) means something went wrong.

what exactly does "hook" mean here?

From the paragraph "Git Hooks": "a way to fire off custom scripts when certain important actions occur", which fits into the definition of "a mechanism that allows developers to extend or modify an existing application's behavior by injecting custom code."

"Hook" in software seems a misnomer. Really, it's a glorified API call, right?

It's an API call in a broad sense, but calling a script isn't commonly referred to as an "API call".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants